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.
7 8 9 10 |
# File 'lib/sequent/core/helpers/array_with_type.rb', line 7 def initialize(item_type) raise "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.
5 6 7 |
# File 'lib/sequent/core/helpers/array_with_type.rb', line 5 def item_type @item_type end |
Instance Method Details
#candidate?(value) ⇒ Boolean
20 21 22 |
# File 'lib/sequent/core/helpers/array_with_type.rb', line 20 def candidate?(value) value.is_a?(Array) end |
#deserialize_from_json(value) ⇒ Object
12 13 14 |
# File 'lib/sequent/core/helpers/array_with_type.rb', line 12 def deserialize_from_json(value) value.nil? ? nil : value.map { |item| item_type.deserialize_from_json(item) } end |
#to_s ⇒ Object
16 17 18 |
# File 'lib/sequent/core/helpers/array_with_type.rb', line 16 def to_s "Sequent::Core::Helpers::ArrayWithType.new(#{item_type})" end |