def hash_attr(attr, metadata={})
      add_attribute(attr, :hash, metadata)
      define_method("#{attr}=") do |arg|
        instance_variable_set("@#{attr}", arg || {})
      end
    end
def hash_attr(attr, metadata={})
      add_attribute(attr, :hash, metadata)
      define_method("#{attr}=") do |arg|
        instance_variable_set("@#{attr}", arg || {})
      end
    end
Defines a hash attribute. This is named hash_attr instead of hash
 to avoid a conflict with Object#hash

 @params [Symbol] attr The name of the attribute
 @params [Hash{Symbol => Object}] metadata The metadata for the attribute