Module: SwitchSearchable::SearchEngine::Elasticsearch

Defined in:
lib/switch_searchable/search_engine/elasticsearch.rb

Defined Under Namespace

Modules: ClassMethods Classes: BadConfiguration, BadDataType

Class Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/switch_searchable/search_engine/elasticsearch.rb', line 8

def included(klass)
  raise_errors

  klass.class_eval do
    extend ClassMethods
    include ::Elasticsearch::Model
    include ::Elasticsearch::Model::Callbacks
  end
end

.raise_errorsObject

Raises:



18
19
20
21
22
23
# File 'lib/switch_searchable/search_engine/elasticsearch.rb', line 18

def raise_errors
  raise(
    BadConfiguration,
    "Please add ELASTICSEARCH_HOST in your environment variables"
  ) unless ENV["ELASTICSEARCH_HOST"]
end