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)



70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/elasticsearch/persistence/model/base.rb', line 70

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