Class: Humanoid::Collections::Slaves
- Includes:
- Mimic
- Defined in:
- lib/humanoid/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.
Methods included from Mimic
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, "humanoid_people")
32 33 34 35 36 |
# File 'lib/humanoid/collections/slaves.rb', line 32 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.
7 8 9 |
# File 'lib/humanoid/collections/slaves.rb', line 7 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.
22 23 24 |
# File 'lib/humanoid/collections/slaves.rb', line 22 def empty? @iterator.nil? end |