Module: Elastify

Defined in:
lib/elastify.rb,
lib/elastify/version.rb,
lib/elastify/errors/base.rb,
lib/elastify/errors/connection.rb,
lib/elastify/errors/bad_request.rb,
lib/elastify/configurators/model.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, Configurators, Errors, Helpers Classes: ElastifyError

Constant Summary collapse

VERSION =
'0.2.3'

Class Method Summary collapse

Class Method Details

.configsObject



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

def configs
    return Rails.application.config.elastify[:configs]
end

.configure(&block) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/elastify.rb', line 16

def configure &block
    mappings = {}
    configs = OpenStruct.new({
        base_url: 'http://localhost:9200',
        mappings_path: Rails.root.join('config/elastify/mappings')
    })
    block.call(configs) if block_given?
    dir = configs.mappings_path
    if Dir.exist?(dir)
        Dir.glob("#{dir}/*.json") do |file_path|
            mappings[File.basename(file_path, '.json')] = JSON.parse(File.read(file_path))
        end
    end
    Rails.application.config.elastify = {
        configs: configs,
        mappings: mappings,
    }
end

.mappingsObject



39
40
41
# File 'lib/elastify.rb', line 39

def mappings
    return Rails.application.config.elastify[:mappings]
end