Class: Lutaml::Model::MappingHash
- Inherits:
-
Hash
- Object
- Hash
- Lutaml::Model::MappingHash
show all
- Defined in:
- lib/lutaml/model/mapping_hash.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of MappingHash.
8
9
10
11
12
13
|
# File 'lib/lutaml/model/mapping_hash.rb', line 8
def initialize
@ordered = false
@item_order = []
super
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args) ⇒ Object
53
54
55
56
57
58
|
# File 'lib/lutaml/model/mapping_hash.rb', line 53
def method_missing(method_name, *args)
value = self[method_name] || self[method_name.to_s]
return value if value
super
end
|
Instance Attribute Details
#node ⇒ Object
Returns the value of attribute node.
6
7
8
|
# File 'lib/lutaml/model/mapping_hash.rb', line 6
def node
@node
end
|
#ordered ⇒ Object
Returns the value of attribute ordered.
6
7
8
|
# File 'lib/lutaml/model/mapping_hash.rb', line 6
def ordered
@ordered
end
|
Instance Method Details
#assign_or_append_value(key, value) ⇒ Object
41
42
43
44
45
46
47
|
# File 'lib/lutaml/model/mapping_hash.rb', line 41
def assign_or_append_value(key, value)
self[key] = if self[key]
[self[key], value].flatten
else
value
end
end
|
#fetch(key) ⇒ Object
19
20
21
|
# File 'lib/lutaml/model/mapping_hash.rb', line 19
def fetch(key)
self[key.to_s] || self[key.to_sym]
end
|
#item_order ⇒ Object
15
16
17
|
# File 'lib/lutaml/model/mapping_hash.rb', line 15
def item_order
@item_order
end
|
#item_order=(order) ⇒ Object
27
28
29
30
31
|
# File 'lib/lutaml/model/mapping_hash.rb', line 27
def item_order=(order)
raise "`item order` must be an array" unless order.is_a?(Array)
@item_order = order
end
|
#key_exist?(key) ⇒ Boolean
23
24
25
|
# File 'lib/lutaml/model/mapping_hash.rb', line 23
def key_exist?(key)
key?(key.to_s) || key?(key.to_sym)
end
|
#ordered? ⇒ Boolean
49
50
51
|
# File 'lib/lutaml/model/mapping_hash.rb', line 49
def ordered?
@ordered
end
|
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
60
61
62
63
64
65
|
# File 'lib/lutaml/model/mapping_hash.rb', line 60
def respond_to_missing?(method_name, include_private = false)
key_present = key?(method_name) || key?(method_name.to_s)
return true if key_present
super
end
|
#text ⇒ Object
33
34
35
|
# File 'lib/lutaml/model/mapping_hash.rb', line 33
def text
self["#cdata-section"] || self["text"]
end
|
#text? ⇒ Boolean
37
38
39
|
# File 'lib/lutaml/model/mapping_hash.rb', line 37
def text?
key?("#cdata-section") || key?("text")
end
|