Class: Sequent::Core::Helpers::ArrayWithType
- Inherits:
-
Object
- Object
- Sequent::Core::Helpers::ArrayWithType
- Defined in:
- lib/sequent/core/helpers/array_with_type.rb
Instance Attribute Summary collapse
-
#item_type ⇒ Object
Returns the value of attribute item_type.
Instance Method Summary collapse
- #candidate?(value) ⇒ Boolean
- #deserialize_from_json(value) ⇒ Object
-
#initialize(item_type) ⇒ ArrayWithType
constructor
A new instance of ArrayWithType.
- #to_s ⇒ Object
Constructor Details
#initialize(item_type) ⇒ ArrayWithType
Returns a new instance of ArrayWithType.
9 10 11 12 13 |
# File 'lib/sequent/core/helpers/array_with_type.rb', line 9 def initialize(item_type) fail 'needs a item_type' unless item_type @item_type = item_type end |
Instance Attribute Details
#item_type ⇒ Object
Returns the value of attribute item_type.
7 8 9 |
# File 'lib/sequent/core/helpers/array_with_type.rb', line 7 def item_type @item_type end |
Instance Method Details
#candidate?(value) ⇒ Boolean
23 24 25 |
# File 'lib/sequent/core/helpers/array_with_type.rb', line 23 def candidate?(value) value.is_a?(Array) end |
#deserialize_from_json(value) ⇒ Object
15 16 17 |
# File 'lib/sequent/core/helpers/array_with_type.rb', line 15 def deserialize_from_json(value) value.nil? ? nil : value.map { |item| item_type.deserialize_from_json(item) } end |
#to_s ⇒ Object
19 20 21 |
# File 'lib/sequent/core/helpers/array_with_type.rb', line 19 def to_s "Sequent::Core::Helpers::ArrayWithType.new(#{item_type})" end |