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
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
#[], #array?, #as, build, #compile_fragment, #default_for, #evaluate_option, #get, #getter, #has_default?, #initialize, #name, #parse_filter, #read_fragment, #render_filter, #render_fragment, #representable?, #representer_module, #representer_module_for, #set, #setter, #skipable_empty_value?, #typed?, #uncompile_fragment, #write_fragment
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 |
# File 'lib/representable/hash/binding.rb', line 6 def self.build_for(definition, *args) # TODO: remove default arg. 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
26 27 28 |
# File 'lib/representable/hash/binding.rb', line 26 def deserialize_method :from_hash end |
#read(hash) ⇒ Object
12 13 14 15 16 |
# File 'lib/representable/hash/binding.rb', line 12 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
22 23 24 |
# File 'lib/representable/hash/binding.rb', line 22 def serialize_method :to_hash end |
#write(hash, fragment) ⇒ Object
18 19 20 |
# File 'lib/representable/hash/binding.rb', line 18 def write(hash, fragment) hash[as] = fragment end |