module Elasticsearch::Persistence::Model::Utils

Utility methods for {Elasticsearch::Persistence::Model}

Public Class Methods

lookup_type(type) click to toggle source

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

# File lib/elasticsearch/persistence/model/base.rb, line 74
def lookup_type(type)
  case
  when type == :keyword
    "keyword"
  when type == String
    "text"
  when type == Integer
    "integer"
  when type == Float
    "float"
  when type == Date || type == Time || type == DateTime
    "date"
  when type == Virtus::Attribute::Boolean
    "boolean"
  end
end

Private Instance Methods

lookup_type(type) click to toggle source

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

# File lib/elasticsearch/persistence/model/base.rb, line 74
def lookup_type(type)
  case
  when type == :keyword
    "keyword"
  when type == String
    "text"
  when type == Integer
    "integer"
  when type == Float
    "float"
  when type == Date || type == Time || type == DateTime
    "date"
  when type == Virtus::Attribute::Boolean
    "boolean"
  end
end