Class: Representable::JSON::JSONBinding
- Inherits:
-
Binding
- Object
- Binding
- Representable::JSON::JSONBinding
show all
- Defined in:
- lib/representable/bindings/json_bindings.rb
Instance Attribute Summary
Attributes inherited from Binding
#definition
Instance Method Summary
collapse
#deserialize, #serialize
Constructor Details
#initialize(definition) ⇒ JSONBinding
19
20
21
22
|
# File 'lib/representable/bindings/json_bindings.rb', line 19
def initialize(definition) super
extend ObjectBinding if definition.typed?
end
|
Instance Method Details
#read(hash) ⇒ Object
24
25
26
27
28
29
|
# File 'lib/representable/bindings/json_bindings.rb', line 24
def read(hash)
return FragmentNotFound unless hash.has_key?(definition.from)
fragment = hash[definition.from]
deserialize_from(fragment)
end
|
#write(hash, value) ⇒ Object
31
32
33
|
# File 'lib/representable/bindings/json_bindings.rb', line 31
def write(hash, value)
hash[definition.from] = serialize_for(value)
end
|