Class: Sequent::Core::Helpers::ArrayWithType

Inherits:
Object
  • Object
show all
Defined in:
lib/sequent/core/helpers/array_with_type.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_typeObject

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

Returns:



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_sObject



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