Class: Mongoid::Collections::Slaves

Inherits:
Object
  • Object
show all
Defined in:
lib/mongoid/collections/slaves.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(slaves, name) ⇒ Slaves

Create the new database reader. Will create a collection from the slave databases and cycle through them on each read.

Example:

Reader.new(slaves, "mongoid_people")



33
34
35
36
37
# File 'lib/mongoid/collections/slaves.rb', line 33

def initialize(slaves, name)
  unless slaves.blank?
    @iterator = CyclicIterator.new(slaves.collect { |db| db.collection(name) })
  end
end

Instance Attribute Details

#iteratorObject (readonly)

Returns the value of attribute iterator.



6
7
8
# File 'lib/mongoid/collections/slaves.rb', line 6

def iterator
  @iterator
end

Instance Method Details

#empty?Boolean

Is the collection of slaves empty or not?

Return:

True is the iterator is not set, false if not.

Returns:



23
24
25
# File 'lib/mongoid/collections/slaves.rb', line 23

def empty?
  @iterator.nil?
end