Class: Humanoid::Collections::Slaves

Inherits:
Object
  • Object
show all
Includes:
Mimic
Defined in:
lib/humanoid/collections/slaves.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Mimic

included

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

#iteratorObject (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.

Returns:



22
23
24
# File 'lib/humanoid/collections/slaves.rb', line 22

def empty?
  @iterator.nil?
end