Class: Representable::Hash::Binding

Inherits:
Binding
  • Object
show all
Defined in:
lib/representable/hash/binding.rb

Direct Known Subclasses

Collection, YAML::Binding

Defined Under Namespace

Classes: Collection

Instance Attribute Summary

Attributes inherited from Binding

#cached_representer, #getter, #name, #setter

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Binding

#[], #default_for, #initialize, #skipable_empty_value?

Methods included from Binding::ClassDeprecatable

#build

Methods included from Binding::Factories

#collect_for, #default_parse_fragment_functions, #default_parse_init_functions, #default_post_functions, #default_render_fragment_functions, #default_render_init_functions, #parse_functions, #pipeline_for, #render_functions

Methods included from Binding::Deprecatable

#compile_fragment, #uncompile_fragment

Constructor Details

This class inherits a constructor from Representable::Binding

Class Method Details

.build_for(definition) ⇒ Object



6
7
8
9
# File 'lib/representable/hash/binding.rb', line 6

def self.build_for(definition)
  return Collection.new(definition) if definition.array?
  new(definition)
end

Instance Method Details

#deserialize_methodObject



23
24
25
# File 'lib/representable/hash/binding.rb', line 23

def deserialize_method
  :from_hash
end

#read(hash, as) ⇒ Object



11
12
13
# File 'lib/representable/hash/binding.rb', line 11

def read(hash, as)
  hash.has_key?(as) ? hash[as] : FragmentNotFound
end

#serialize_methodObject



19
20
21
# File 'lib/representable/hash/binding.rb', line 19

def serialize_method
  :to_hash
end

#write(hash, fragment, as) ⇒ Object



15
16
17
# File 'lib/representable/hash/binding.rb', line 15

def write(hash, fragment, as)
  hash[as] = fragment
end