module Elasticfusion

An instance of this class represents a single search. It encapsulates all custom search features (advanced query parsing, query building, etc.)

Constants

VERSION

Public Class Methods

define(cls, &block) click to toggle source
# File lib/elasticfusion/definition.rb, line 7
def self.define(cls, &block)
  cls.class_eval do
    include Elasticsearch::Model

    def self.elasticfusion(&block)
      @elasticfusion ||= Model::Settings.new(self, &block)
    end
  end

  cls.class_eval(&block)

  # Model extensions may rely on settings set with the block
  # and should only be included after evaluating it.
  cls.class_eval do
    include Model::Indexing
    include Model::Searching
  end
end
elasticfusion(&block) click to toggle source
# File lib/elasticfusion/definition.rb, line 11
def self.elasticfusion(&block)
  @elasticfusion ||= Model::Settings.new(self, &block)
end
load_index_definitions() click to toggle source

Call this method from within an autoloaded file (e.g. models/application_record.rb) to instantiate index definitions and refresh them in development, when Rails autoreloads constants.

# File lib/elasticfusion/loader.rb, line 6
def self.load_index_definitions
  Dir.glob(Rails.root.join('app', 'indexes', '*.rb'), &method(:load))
end