Class: INatGet::Data::Helper::Field::Iconic Private

Inherits:
Set show all
Defined in:
lib/inat-get/data/helpers/defs/iconic.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary

Attributes inherited from INatGet::Data::Helper::Field

#helper, #key

Instance Method Summary collapse

Methods inherited from Set

#prepare, #valid?

Methods inherited from INatGet::Data::Helper::Field

#prepare, #to_api, #valid?

Constructor Details

#initialize(helper, key) ⇒ Iconic

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Iconic.



8
9
10
# File 'lib/inat-get/data/helpers/defs/iconic.rb', line 8

def initialize helper, key
  super helper, key, lambda { |v| v.is_a?(String) || v.is_a?(Enumerable) || v.is_a?(INatGet::Data::Enum::Iconic) }
end

Instance Method Details

#to_sequel(value) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



12
13
14
# File 'lib/inat-get/data/helpers/defs/iconic.rb', line 12

def to_sequel value
  { taxon_id: value_to_sequel(value) }
end

#value_to_sequel(value) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/inat-get/data/helpers/defs/iconic.rb', line 16

def value_to_sequel value
  case value
  when Enumerable
    value.map { |v| value_to_sequel(v) }.to_set
  when INatGet::Data::Enum::Iconic
    value.taxon_id
  when String
    INatGet::Data::Enum::Iconic::parse(value).taxon_id
  else
    value
  end
end