lib/representable/binding.rb in representable-1.2.7 vs lib/representable/binding.rb in representable-1.2.8

- old
+ new

@@ -1,15 +1,15 @@ +require 'delegate' + module Representable - class Binding + # The Binding wraps the Definition instance for this property and provides methods to read/write fragments. + class Binding < SimpleDelegator class FragmentNotFound end - - attr_reader :definition # TODO: merge Binding and Definition. - - def initialize(definition) - @definition = definition + def definition # TODO: remove in 1.4. + raise "Binding#definition is no longer supported as all Definition methods are now delegated automatically." end # Main entry point for rendering/parsing a property object. def serialize(value) value @@ -31,11 +31,11 @@ def deserialize(*) extend_for(super) end def extend_for(object) - if mod = definition.representer_module + if mod = representer_module object.extend(*mod) end object end @@ -54,10 +54,10 @@ # DISCUSS: does it make sense to skip deserialization of nil-values here? super(create_object).send(deserialize_method, data) end def create_object - definition.sought_type.new + sought_type.new end end end end