Module: Elasticsearch::Persistence::Model::Utils

Defined in:
lib/elasticsearch/persistence/model/base.rb

Overview

Utility methods for Elasticsearch::Persistence::Model

Class Method Summary collapse

Class Method Details

.lookup_type(type) ⇒ Object

Return Elasticsearch type based on passed Ruby class (used in the ‘attribute` method)



58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/elasticsearch/persistence/model/base.rb', line 58

def lookup_type(type)
  case
    when type == String
      'string'
    when type == Integer
      'integer'
    when type == Float
      'float'
    when type == Date || type == Time || type == DateTime
      'date'
    when type == Virtus::Attribute::Boolean
      'boolean'
  end
end