lib/representable/hash/collection.rb in representable-2.3.0 vs lib/representable/hash/collection.rb in representable-2.4.0.rc1

- old
+ new

@@ -4,11 +4,11 @@ def self.included(base) base.class_eval do include Representable::Hash extend ClassMethods - representable_attrs.add(:_self, {:collection => true}) + property(:_self, {:collection => true}) end end module ClassMethods @@ -17,17 +17,21 @@ end end def create_representation_with(doc, options, format) - bin = representable_mapper(format, options).bindings(represented, options).first - bin.render_fragment(represented, doc) + bin = representable_bindings_for(format, options).first + + Collect[*bin.default_render_fragment_functions]. + (represented, {doc: doc, fragment: represented, user_options: options, binding: bin, represented: represented}) end def update_properties_from(doc, options, format) - bin = representable_mapper(format, options).bindings(represented, options).first - #value = bin.deserialize_from(doc) - value = Deserializer::Collection.new(bin).call(doc) + bin = representable_bindings_for(format, options).first + + value = Collect[*bin.default_parse_fragment_functions]. + (doc, fragment: doc, document: doc, user_options: options, binding: bin, represented: represented) + represented.replace(value) end end end