module Mebla

A wrapper for slingshot elastic-search adapter for Mongoid

A wrapper for slingshot elastic-search adapter for Mongoid

A wrapper for slingshot elastic-search adapter for Mongoid

A wrapper for slingshot elastic-search adapter for Mongoid

A wrapper for slingshot elastic-search adapter for Mongoid

A wrapper for slingshot elastic-search adapter for Mongoid

A wrapper for slingshot elastic-search adapter for Mongoid

A wrapper for slingshot elastic-search adapter for Mongoid

A wrapper for slingshot elastic-search adapter for Mongoid

A wrapper for slingshot elastic-search adapter for Mongoid

A wrapper for slingshot elastic-search adapter for Mongoid

A wrapper for slingshot elastic-search adapter for Mongoid

A wrapper for slingshot elastic-search adapter for Mongoid

A wrapper for slingshot elastic-search adapter for Mongoid

Public Class Methods

configure() { |instance| ... } click to toggle source

Configure Mebla

Example

Mebla.configure do |config|

index = "mebla_index"
host = "localhost"
port = 9200

end

# File lib/mebla.rb, line 80
def self.configure(&block)
  yield Mebla::Configuration.instance
end
context() click to toggle source

Returns Mebla’s context for minipulating the index @return [nil]

# File lib/mebla.rb, line 30
def self.context
  if @@context.nil?
    @@mebla_mutex.synchronize do
      if @@context.nil?
        @@context = Mebla::Context.new          
      end
    end
  end
  
  @@context
end
elasticsearch?() click to toggle source

Check if elasticsearch is running @return [Boolean]

# File lib/mebla.rb, line 64
def self.elasticsearch?
  result = Slingshot::Configuration.client.get "#{Slingshot::Configuration.url}/_status"
  return (result =~ /error/) ? false: true
rescue RestClient::Exception
  false
end
log(message, level = :none) click to toggle source

Writes out a message to the log file according to the level given @note If no level is given a message of type Logger::UNKNOWN will be written to the log file @param [String] message @param [Symbol] level can be :debug, :warn or :info @return [nil]

# File lib/mebla.rb, line 90
def self.log(message, level = :none)    
  case level
  when :debug
    hook = "mebla_debug.mebla"
  when :warn
    hook = "mebla_warn.mebla"
  when :info
    hook = "mebla_info.mebla"
  else
    hook = "mebla_unknown.mebla"
  end
  
  ::ActiveSupport::Notifications.
    instrument(hook, :message => message)
end
mongoid?() click to toggle source

Check if mongoid is loaded @return [Boolean]

# File lib/mebla.rb, line 52
def self.mongoid?
  !defined?(Mongoid).nil?
end
reset_context!() click to toggle source

Resets the context (reloads Mebla) @return [nil]

# File lib/mebla.rb, line 44
def self.reset_context!
  @@mebla_mutex.synchronize do
    @@context = nil
  end
end
slingshot?() click to toggle source

Check if slingshot is loaded @return [Boolean]

# File lib/mebla.rb, line 58
def self.slingshot?
  !defined?(Slingshot).nil?
end