Class: Representable::YAML::Binding
Defined Under Namespace
Classes: Collection
Instance Attribute Summary
Attributes inherited from Binding
#represented, #user_options
Class Method Summary
collapse
Instance Method Summary
collapse
#read
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
Class Method Details
.build_for(definition, *args) ⇒ Object
6
7
8
9
|
# File 'lib/representable/yaml/binding.rb', line 6
def self.build_for(definition, *args)
return Collection.new(definition, *args) if definition.array?
new(definition, *args)
end
|
Instance Method Details
#deserialize_method ⇒ Object
31
32
33
|
# File 'lib/representable/yaml/binding.rb', line 31
def deserialize_method
:from_hash
end
|
#node_for(fragment) ⇒ Object
17
18
19
|
# File 'lib/representable/yaml/binding.rb', line 17
def node_for(fragment)
write_scalar(fragment)
end
|
#serialize_method ⇒ Object
27
28
29
|
# File 'lib/representable/yaml/binding.rb', line 27
def serialize_method
:to_ast
end
|
#write(map, fragment) ⇒ Object
11
12
13
14
|
# File 'lib/representable/yaml/binding.rb', line 11
def write(map, fragment)
map.children << Psych::Nodes::Scalar.new(as)
map.children << node_for(fragment) end
|
#write_scalar(value) ⇒ Object
21
22
23
24
25
|
# File 'lib/representable/yaml/binding.rb', line 21
def write_scalar(value)
return value if typed?
Psych::Nodes::Scalar.new(value.to_s)
end
|