module NoBrainer::Criteria::Enumerable

Public Instance Methods

close() click to toggle source
# File lib/no_brainer/criteria/enumerable.rb, line 13
def close
  @close_cursor = true
  @cursor.close if NoBrainer::Config.driver == :em
  self
end
each(options={}, &block) click to toggle source
# File lib/no_brainer/criteria/enumerable.rb, line 4
def each(options={}, &block)
  return enum_for(:each, options) unless block
  run.tap { |cursor| @cursor = cursor }.each do |attrs|
    return close if @close_cursor
    block.call(instantiate_doc(attrs))
  end
  self
end
method_missing(name, *args, &block) click to toggle source

TODO Make something a bit more efficent ?

Calls superclass method
# File lib/no_brainer/criteria/enumerable.rb, line 29
def method_missing(name, *args, &block)
  return super unless [].respond_to?(name)
  to_a.__send__(name, *args, &block)
end
respond_to?(name, include_private = false) click to toggle source

TODO test that

Calls superclass method
# File lib/no_brainer/criteria/enumerable.rb, line 24
def respond_to?(name, include_private = false)
  super || [].respond_to?(name)
end
to_a() click to toggle source
# File lib/no_brainer/criteria/enumerable.rb, line 19
def to_a
  each.to_a.freeze
end