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.
6
7
8
9
10
11
|
# File 'lib/lutaml/model/mapping_hash.rb', line 6
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
43
44
45
46
47
48
|
# File 'lib/lutaml/model/mapping_hash.rb', line 43
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.
4
5
6
|
# File 'lib/lutaml/model/mapping_hash.rb', line 4
def node
@node
end
|
#ordered ⇒ Object
Returns the value of attribute ordered.
4
5
6
|
# File 'lib/lutaml/model/mapping_hash.rb', line 4
def ordered
@ordered
end
|
Instance Method Details
#fetch(key) ⇒ Object
17
18
19
|
# File 'lib/lutaml/model/mapping_hash.rb', line 17
def fetch(key)
self[key.to_s] || self[key.to_sym]
end
|
#item_order ⇒ Object
13
14
15
|
# File 'lib/lutaml/model/mapping_hash.rb', line 13
def item_order
@item_order&.map { |key| normalize(key) } || keys
end
|
#item_order=(order) ⇒ Object
25
26
27
28
29
|
# File 'lib/lutaml/model/mapping_hash.rb', line 25
def item_order=(order)
raise "`item order` must be an array" unless order.is_a?(Array)
@item_order = order
end
|
#key_exist?(key) ⇒ Boolean
21
22
23
|
# File 'lib/lutaml/model/mapping_hash.rb', line 21
def key_exist?(key)
key?(key.to_s) || key?(key.to_sym)
end
|
#ordered? ⇒ Boolean
39
40
41
|
# File 'lib/lutaml/model/mapping_hash.rb', line 39
def ordered?
@ordered
end
|
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
50
51
52
53
54
55
|
# File 'lib/lutaml/model/mapping_hash.rb', line 50
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
31
32
33
|
# File 'lib/lutaml/model/mapping_hash.rb', line 31
def text
self["#cdata-section"] || self["text"]
end
|
#text? ⇒ Boolean
35
36
37
|
# File 'lib/lutaml/model/mapping_hash.rb', line 35
def text?
key?("#cdata-section") || key?("text")
end
|