Module: Representable::HashMethods
- Included in:
- JSON::Hash, XML::AttributeHash, XML::Hash
- Defined in:
- lib/representable/hash_methods.rb
Instance Method Summary collapse
- #create_representation_with(doc, options, format) ⇒ Object
-
#representable_attrs ⇒ Object
FIXME: refactor Definition so we can simply add options in #items to existing definition.
- #update_properties_from(doc, options, format) ⇒ Object
Instance Method Details
#create_representation_with(doc, options, format) ⇒ Object
10 11 12 13 14 |
# File 'lib/representable/hash_methods.rb', line 10 def create_representation_with(doc, , format) bin = representable_mapper(format, ).bindings.first hash = filter_keys_for(represented, ) bin.write(doc, hash) end |
#representable_attrs ⇒ Object
FIXME: refactor Definition so we can simply add options in #items to existing definition.
4 5 6 7 8 |
# File 'lib/representable/hash_methods.rb', line 4 def representable_attrs attrs = super attrs << Definition.new(*definition_opts) if attrs.size == 0 attrs end |
#update_properties_from(doc, options, format) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/representable/hash_methods.rb', line 16 def update_properties_from(doc, , format) bin = representable_mapper(format, ).bindings.first hash = filter_keys_for(doc, ) value = bin.deserialize_from(hash) represented.replace(value) end |