Class: Representable::YAML::PropertyBinding
Instance Attribute Summary
Attributes inherited from Binding
#represented, #user_options
Class Method Summary
collapse
Instance Method Summary
collapse
#deserialize_from, #read
#create_object, #deserialize
Methods inherited from Binding
build, #compile_fragment, #get, #initialize, #read_fragment, #read_fragment_for, #set, #uncompile_fragment, #write_fragment, #write_fragment_for
#representer_module_for
Class Method Details
.build_for(definition, *args) ⇒ Object
6
7
8
9
|
# File 'lib/representable/bindings/yaml_bindings.rb', line 6
def self.build_for(definition, *args)
return CollectionBinding.new(definition, *args) if definition.array?
new(definition, *args)
end
|
Instance Method Details
#deserialize_method ⇒ Object
30
31
32
|
# File 'lib/representable/bindings/yaml_bindings.rb', line 30
def deserialize_method
:from_hash
end
|
#serialize(value) ⇒ Object
16
17
18
|
# File 'lib/representable/bindings/yaml_bindings.rb', line 16
def serialize(value)
write_scalar super(value)
end
|
#serialize_method ⇒ Object
26
27
28
|
# File 'lib/representable/bindings/yaml_bindings.rb', line 26
def serialize_method
:to_ast
end
|
#write(map, value) ⇒ Object
11
12
13
14
|
# File 'lib/representable/bindings/yaml_bindings.rb', line 11
def write(map, value)
map.children << Psych::Nodes::Scalar.new(from)
map.children << serialize(value) end
|
#write_scalar(value) ⇒ Object
20
21
22
23
24
|
# File 'lib/representable/bindings/yaml_bindings.rb', line 20
def write_scalar(value)
return value if typed?
Psych::Nodes::Scalar.new(value.to_s)
end
|