Class: Mongoid::Collections::Slaves
- Defined in:
- lib/mongoid/collections/slaves.rb
Instance Attribute Summary collapse
-
#iterator ⇒ Object
readonly
Returns the value of attribute iterator.
Instance Method Summary collapse
-
#empty? ⇒ Boolean
Is the collection of slaves empty or not?.
-
#initialize(slaves, name) ⇒ Slaves
constructor
Create the new database reader.
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
#iterator ⇒ Object (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.
23 24 25 |
# File 'lib/mongoid/collections/slaves.rb', line 23 def empty? @iterator.nil? end |