Module: Elastify

Defined in:
lib/elastify.rb,
lib/elastify/model.rb,
lib/elastify/config.rb,
lib/elastify/version.rb,
lib/elastify/errors/base.rb,
lib/elastify/errors/connection.rb,
lib/elastify/errors/bad_request.rb,
lib/elastify/helpers/query_builder.rb,
lib/elastify/helpers/elastic_search/document.rb,
lib/elastify/helpers/elastic_search/connector.rb,
lib/elastify/helpers/elastic_search/search_result.rb,
lib/elastify/helpers/elastic_search/search_result_collection.rb

Defined Under Namespace

Modules: ActiveRecordExtensions, Errors, Helpers Classes: Config, Model

Constant Summary collapse

VERSION =
'0.2.5'

Class Method Summary collapse

Class Method Details

.configsObject



24
25
26
27
# File 'lib/elastify.rb', line 24

def configs
    Rails.application.config.elastify_configs = Elastify::Config.new unless Rails.application.config.respond_to?(:elastify_configs)
    Rails.application.config.elastify_configs
end

.init(&block) ⇒ Object



19
20
21
22
# File 'lib/elastify.rb', line 19

def init(&block)
    load_configs(block)
    load_models
end

.modelsObject



29
30
31
32
# File 'lib/elastify.rb', line 29

def models
    Rails.application.config.elastify_models = {} unless Rails.application.config.respond_to?(:elastify_models)
    Rails.application.config.elastify_models
end

.register_model(model_name) {|model| ... } ⇒ Object

Yields:

  • (model)


34
35
36
37
38
# File 'lib/elastify.rb', line 34

def register_model(model_name)
    model = Elastify::Model.new
    yield(model) if block_given?
    models[model_name] = model
end