module Elastics::ModelIndexer
Public Class Methods
elastics()
click to toggle source
# File lib/elastics/model_indexer.rb, line 9 def self.elastics; @elastics end
elastics_in_batches(options={}, &block)
click to toggle source
# File lib/elastics/model_indexer.rb, line 12 def self.elastics_in_batches(options={}, &block) find_in_batches(options, &block) end
included(base)
click to toggle source
# File lib/elastics/model_indexer.rb, line 4 def self.included(base) base.class_eval do @elastics ||= ClassProxy::Base.new(base) @elastics.extend(ClassProxy::ModelSyncer) @elastics.extend(ClassProxy::ModelIndexer).init def self.elastics; @elastics end case when respond_to?(:find_in_batches) def self.elastics_in_batches(options={}, &block) find_in_batches(options, &block) end when defined?(Mongoid::Document) && include?(Mongoid::Document) def self.elastics_in_batches(options={}, &block) 0.step(count, options[:batch_size]) do |offset| block.call limit(options[:batch_size]).skip(offset).to_a end end end end end
Public Instance Methods
elastics()
click to toggle source
# File lib/elastics/model_indexer.rb, line 25 def elastics @elastics ||= InstanceProxy::ModelIndexer.new(self) end
elastics_action()
click to toggle source
# File lib/elastics/model_indexer.rb, line 37 def elastics_action 'index' end
elastics_indexable?()
click to toggle source
# File lib/elastics/model_indexer.rb, line 33 def elastics_indexable? true end
elastics_source()
click to toggle source
# File lib/elastics/model_indexer.rb, line 29 def elastics_source attributes.reject {|k| k.to_s =~ /^_*id$/} end