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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.build_for(definition) ⇒ Object



6
7
8
9
10
# 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_method ⇒ Object



25
26
27
# File 'lib/representable/hash/binding.rb', line 25

def deserialize_method
  :from_hash
end

#read(hash, as) ⇒ Object



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

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

#serialize_method ⇒ Object



21
22
23
# File 'lib/representable/hash/binding.rb', line 21

def serialize_method
  :to_hash
end

#write(hash, fragment, as) ⇒ Object



17
18
19
# File 'lib/representable/hash/binding.rb', line 17

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