Class: Seahorse::ListType
- Inherits:
-
Type
- Object
- Type
- Seahorse::ListType
show all
- Defined in:
- lib/seahorse/type.rb
Instance Attribute Summary collapse
Attributes inherited from Type
#as, #documentation, #header, #location, #model, #name, #required, #uri
Instance Method Summary
collapse
Methods inherited from Type
#default_type, inspect, #inspect, #pull_value, type, #type, type=
Constructor Details
#initialize(*args) ⇒ ListType
Returns a new instance of ListType.
120
121
122
|
# File 'lib/seahorse/type.rb', line 120
def initialize(*args)
super
end
|
Instance Attribute Details
#collection ⇒ Object
Returns the value of attribute collection.
118
119
120
|
# File 'lib/seahorse/type.rb', line 118
def collection
@collection
end
|
Instance Method Details
#add(shape) ⇒ Object
126
127
128
|
# File 'lib/seahorse/type.rb', line 126
def add(shape)
self.collection = shape
end
|
#complex? ⇒ Boolean
124
|
# File 'lib/seahorse/type.rb', line 124
def complex?; true end
|
136
137
138
139
|
# File 'lib/seahorse/type.rb', line 136
def from_input(data, filter = true)
data.each_with_index {|v, i| data[i] = collection.from_input(v, filter) }
data
end
|
#to_hash ⇒ Object
130
131
132
133
134
|
# File 'lib/seahorse/type.rb', line 130
def to_hash
hash = super
hash['members'] = collection ? collection.to_hash : {}
hash
end
|
#to_output(data) ⇒ Object
141
142
143
|
# File 'lib/seahorse/type.rb', line 141
def to_output(data)
pull_value(data).map {|v| collection.to_output(v) }
end
|
#to_strong_params ⇒ Object
145
146
147
|
# File 'lib/seahorse/type.rb', line 145
def to_strong_params
collection.complex? ? collection.to_strong_params : []
end
|