lib/elasticsearch/extensions/documents.rb in elasticsearch-documents-0.0.1 vs lib/elasticsearch/extensions/documents.rb in elasticsearch-documents-0.1.0
- old
+ new
@@ -1,7 +1,8 @@
require "elasticsearch"
require "logger"
+require "ostruct"
require "elasticsearch/extensions/documents/version"
require "elasticsearch/extensions/documents/document"
require "elasticsearch/extensions/documents/index"
require "elasticsearch/extensions/documents/indexer"
require "elasticsearch/extensions/documents/queryable"
@@ -13,35 +14,23 @@
class << self
attr_accessor :client, :configuration
def client
- @client ||= Elasticsearch::Client.new({
- host: self.configuration.url,
- log: self.configuration.log,
- })
+ Elasticsearch::Client.new(configuration.client.marshal_dump)
end
def configure
- self.configuration ||= Configuration.new
+ self.configuration ||= OpenStruct.new(client: OpenStruct.new)
yield configuration
end
def index_name
self.configuration.index_name
end
def logger
- self.configuration.logger
- end
- end
-
- class Configuration
- attr_accessor :url, :index_name, :mappings, :settings, :log, :logger
-
- def initialize
- @logger = Logger.new(STDOUT)
- @log = true
+ self.configuration.client.logger ||= Logger.new(STDERR)
end
end
end
end