Class: Representable::Hash::Binding
- Defined in:
- lib/representable/hash/binding.rb
Direct Known Subclasses
Defined Under Namespace
Classes: Collection, Hash
Instance Attribute Summary
Attributes inherited from Binding
#array, #cached_representer, #getter, #has_default, #name, #representable, #represented, #setter, #skip_filters, #typed, #user_options
Class Method Summary collapse
-
.build_for(definition, *args) ⇒ Object
TODO: remove default arg.
Instance Method Summary collapse
- #deserialize_method ⇒ Object
- #read(hash) ⇒ Object
- #serialize_method ⇒ Object
- #write(hash, fragment) ⇒ Object
Methods inherited from Binding
#[], #as, build, #compile_fragment, #default_for, #evaluate_option, #get, #initialize, #parse_filter, #read_fragment, #render_filter, #render_fragment, #representer_module_for, #set, #skipable_empty_value?, #uncompile_fragment, #update!, #write_fragment
Methods included from Binding::Factories
#deserializer, #deserializer_class, #populator, #populator_class, #serializer, #serializer_class
Constructor Details
This class inherits a constructor from Representable::Binding
Class Method Details
.build_for(definition, *args) ⇒ Object
TODO: remove default arg.
6 7 8 9 10 11 |
# File 'lib/representable/hash/binding.rb', line 6 def self.build_for(definition, *args) # TODO: remove default arg. # puts "@@@build@@ #{definition.inspect}" return Collection.new(definition, *args) if definition.array? return Hash.new(definition, *args) if definition.hash? new(definition, *args) end |
Instance Method Details
#deserialize_method ⇒ Object
27 28 29 |
# File 'lib/representable/hash/binding.rb', line 27 def deserialize_method :from_hash end |
#read(hash) ⇒ Object
13 14 15 16 17 |
# File 'lib/representable/hash/binding.rb', line 13 def read(hash) return FragmentNotFound unless hash.has_key?(as) # DISCUSS: put it all in #read for performance. not really sure if i like returning that special thing. hash[as] # fragment end |
#serialize_method ⇒ Object
23 24 25 |
# File 'lib/representable/hash/binding.rb', line 23 def serialize_method :to_hash end |
#write(hash, fragment) ⇒ Object
19 20 21 |
# File 'lib/representable/hash/binding.rb', line 19 def write(hash, fragment) hash[as] = fragment end |