Class: Tabry::Models::ConfigList
- Inherits:
-
Object
- Object
- Tabry::Models::ConfigList
show all
- Includes:
- Enumerable
- Defined in:
- lib/tabry/models/config_list.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(raw:, root:, klass:) ⇒ ConfigList
Returns a new instance of ConfigList.
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/tabry/models/config_list.rb', line 12
def initialize(raw:, root:, klass:)
raise "missing root" unless root
raw ||= []
unless raw.is_a?(Array)
raise ConfigError, "#{self.class.name} must be an array. Got #{raw.class}"
end
@unflattened = raw.map { |a| klass.new(raw: a, root: root) }
end
|
Instance Attribute Details
#unflattened ⇒ Object
Returns the value of attribute unflattened.
8
9
10
|
# File 'lib/tabry/models/config_list.rb', line 8
def unflattened
@unflattened
end
|
Instance Method Details
#[](*args) ⇒ Object
31
32
33
|
# File 'lib/tabry/models/config_list.rb', line 31
def [](*args)
to_a.[](*args)
end
|
#each ⇒ Object
35
36
37
|
# File 'lib/tabry/models/config_list.rb', line 35
def each(...)
to_a.each(...)
end
|
#empty? ⇒ Boolean
43
44
45
|
# File 'lib/tabry/models/config_list.rb', line 43
def empty?
to_a.empty?
end
|
#flatten ⇒ Object
27
28
29
|
# File 'lib/tabry/models/config_list.rb', line 27
def flatten
@flatten ||= unflattened.map(&:flatten).flatten
end
|
#length ⇒ Object
39
40
41
|
# File 'lib/tabry/models/config_list.rb', line 39
def length
to_a.length
end
|
#to_a ⇒ Object
23
24
25
|
# File 'lib/tabry/models/config_list.rb', line 23
def to_a
flatten
end
|