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)



64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/elasticsearch/persistence/model/base.rb', line 64

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