Sha256: a1c1bdf3805834e529220378015060b847e80845a2beed39b62a85d7e8b9b63f

Contents?: true

Size: 1.36 KB

Versions: 3

Compression:

Stored size: 1.36 KB

Contents

require "stretcher"
require "active_support/core_ext"
require "elastic_mapper/version"
require "elastic_mapper/mapping"
require "elastic_mapper/index"
require "elastic_mapper/search"

module ElasticMapper

  # The index name to use for ElasticMapper.
  # the models themselves are namespaced
  # by a mapping names.
  #
  # @param index_name [String] name of index.
  def self.index_name=(index_name)
    @@index_name = index_name
  end

  # Return the index name.
  #
  # @return [String] name of index.
  def self.index_name
    @@index_name
  end

  # Return the index associated with the
  # default index name.
  #
  # @return [Stretcher::Index] index object.
  def self.index
    ElasticMapper.server.index(index_name)
  end

  # Allow the ES server to be overriden by an
  # instance with custom initialization.
  #
  # @param server [Stretcher::Server] ES server.
  def self.server=(server)
    @@server = server
  end

  # Return the server object associated with
  # ElasticMapper.
  #
  # @return [Stretcher::Server]
  def self.server
    @@server ||= Stretcher::Server.new
  end

  # Include all of the submodules, so that
  # we can optinally use elasticmapper by
  # simply including the root module.
  def self.included(base)
    base.send(:include, ElasticMapper::Mapping)
    base.send(:include, ElasticMapper::Index)
    base.send(:include, ElasticMapper::Search)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
elastic_mapper-0.2.1 lib/elastic_mapper.rb
elastic_mapper-0.1.0 lib/elastic_mapper.rb
elastic_mapper-0.0.1 lib/elastic_mapper.rb