lib/representable/hash_methods.rb in representable-2.3.0 vs lib/representable/hash_methods.rb in representable-2.4.0.rc1

- old
+ new

@@ -1,19 +1,19 @@ module Representable module HashMethods def create_representation_with(doc, options, format) hash = filter_keys_for!(represented, options) # FIXME: this modifies options and replicates logic from Representable. - bin = representable_mapper(format, options).bindings(represented, options).first + bin = representable_map(options, format).first - bin.render_fragment(hash, doc) # TODO: Use something along Populator, which does + Collect::Hash[*bin.default_render_fragment_functions].extend(Pipeline::Debug).(hash, {doc: doc, user_options: options, binding: bin, represented: represented, decorator: self}) end def update_properties_from(doc, options, format) hash = filter_keys_for!(doc, options) - bin = representable_mapper(format, options).bindings(represented, options).first + bin = representable_map(options, format).first - value = Deserializer::Hash.new(bin).call(hash) - # value = bin.deserialize_from(hash) + value = Collect::Hash[*bin.default_parse_fragment_functions].(hash, fragment: hash, document: doc, binding: bin, represented: represented, user_options: options, decorator: self) + represented.replace(value) end private def filter_keys_for!(hash, options)