Sha256: f55f4f73458de4ae8470357696d3711b9fbf63e794dd160c38fc7024b16406d6

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

require "elastic/railties/utils"
require "elastic/railties/ar_helpers"
require "elastic/railties/ar_middleware"
require "elastic/railties/type_extensions"
require "elastic/railties/query_extensions"
require "elastic/railties/indexable_record"

module Elastic
  class Railtie < Rails::Railtie
    initializer "elastic.configure_rails_initialization" do
      Elastic.configure Rails.application.config_for(:elastic).merge(logger: Rails.logger)

      # Make every activerecord model indexable
      ActiveRecord::Base.send(:include, Elastic::Railties::IndexableRecord)
    end

    rake_tasks do
      load File.expand_path('../railties/tasks/es.rake', __FILE__)
    end

    # TODO: configure generators here too
  end
end

# Expose railties utils at Elastic namespace
module Elastic
  extend Elastic::Railties::Utils
end

# Add activerecord related index helpers
class Elastic::Type
  include Elastic::Railties::TypeExtensions
end

# Add activerecord related query helpers
class Elastic::Query
  include Elastic::Railties::QueryExtensions
end

# Register active record middleware
Elastic.register_middleware Elastic::Railties::ARMiddleware

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
elastic-rails-0.5.0 lib/elastic/railtie.rb