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.



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_typeObject

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

Returns:



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_sObject



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