lib/indexes.rb in indexes-0.0.1 vs lib/indexes.rb in indexes-4.0.0.0

- old
+ new

@@ -1,18 +1,17 @@ -require 'generators/indexes/index_generator' -require 'generators/indexes/install_generator' require 'indexes/dsl/api' require 'indexes/dsl/mappings' require 'indexes/dsl/search' -require 'indexes/dsl/serializer' +require 'indexes/dsl/serialization' +require 'indexes/collection' require 'indexes/concern' require 'indexes/configuration' +require 'indexes/definitions' require 'indexes/index' require 'indexes/pagination' require 'indexes/proxy' require 'indexes/railtie' -require 'indexes/collection' require 'indexes/version' module Indexes class << self @@ -39,47 +38,37 @@ def configuration @configuration ||= Configuration.new end + def definitions + @definitions ||= Definitions.new + end + def define(*args, &block) Proxy.new *args, &block end - def add(*args) - index = Index.new(*args) - registry[index.name] = index - end - - def find(name) - registry[name] - end - alias_method :[], :find - - def each(&block) - registry.values.sort.each &block - end - def build unless client.indices.exists?(index: namespace) client.indices.create( index: namespace, body: { settings: configuration.analysis } ) end - each &:build + definitions.each &:build end - def exist?(type) - client.indices.exists? index: namespace, type: type - end - def rebuild destroy build end + def exist?(type) + client.indices.exists? index: namespace, type: type + end + def destroy if client.indices.exists?(index: namespace) client.indices.delete index: namespace end end @@ -88,15 +77,9 @@ response = client.suggest( index: namespace, body: { suggestions: Dsl::Api.new(args, &configuration.suggestions).to_h } ) response['suggestions'].first['options'].map &:symbolize_keys - end - - private - - def registry - @registry ||= {} end end end