Sha256: 00318a4d8cbbb1979034af6837cf4a8eef7f638a74a6bf426e3f2ac2d563a571
Contents?: true
Size: 1.05 KB
Versions: 18
Compression:
Stored size: 1.05 KB
Contents
# encoding: utf-8 module Mongoid #:nodoc: module Collections #:nodoc: class Slaves include Mimic attr_reader :iterator # All read operations should delegate to the slave connections. # These operations mimic the methods on a Mongo:Collection. # # Example: # # <tt>collection.save({ :name => "Al" })</tt> proxy(:collection, Operations::READ) # Is the collection of slaves empty or not? # # Return: # # True is the iterator is not set, false if not. def empty? @iterator.nil? end # Create the new database reader. Will create a collection from the # slave databases and cycle through them on each read. # # Example: # # <tt>Reader.new(slaves, "mongoid_people")</tt> def initialize(slaves, name) unless slaves.blank? @iterator = CyclicIterator.new(slaves.collect { |db| db.collection(name) }) end end protected def collection @iterator.next end end end end
Version data entries
18 entries across 18 versions & 2 rubygems