Class: Komagire::IdList::Converter

Inherits:
KeyList::Converter show all
Defined in:
lib/komagire/id_list.rb

Instance Attribute Summary

Attributes inherited from KeyList::Converter

#attribute, #content_class_name, #delimiter

Instance Method Summary collapse

Methods inherited from KeyList::Converter

#convert, #convert_to_cskeys, #initialize

Constructor Details

This class inherits a constructor from Komagire::KeyList::Converter

Instance Method Details

#convert_to_cskeys_from_array(values) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/komagire/id_list.rb', line 43

def convert_to_cskeys_from_array(values)
  if values.all? { |v| v.is_a?(String) }
    values.join(delimiter)
  elsif values.all? { |v| v.is_a?(Integer) }
    values.join(delimiter)
  elsif values.all? { |v| v.is_a?(content_class_name.constantize) }
    values.map(&attribute).join(delimiter)
  else
    raise DifferentContentClass
  end
end