Class: Rdomino::DatabaseCollection

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/rdomino/database_collection.rb

Overview

Replicated

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(databases) ⇒ DatabaseCollection

Returns a new instance of DatabaseCollection.



17
18
19
# File 'lib/rdomino/database_collection.rb', line 17

def initialize(databases)
  @databases = databases
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args) ⇒ Object



35
36
37
38
39
# File 'lib/rdomino/database_collection.rb', line 35

def method_missing(m,*args)
  @databases.map do |database|
    database.__send__(m,*args)
  end
end

Instance Attribute Details

#databasesObject (readonly)

Returns the value of attribute databases.



5
6
7
# File 'lib/rdomino/database_collection.rb', line 5

def databases
  @databases
end

Class Method Details

.create_by_path(*db_strings) ⇒ Object



9
10
11
12
13
14
# File 'lib/rdomino/database_collection.rb', line 9

def create_by_path *db_strings
  dbs = db_strings.flatten.map do |db_string|
    Database.new( nil, db_string)            
  end
  new dbs
end

Instance Method Details

#eachObject



21
22
23
24
25
# File 'lib/rdomino/database_collection.rb', line 21

def each
  @databases.each do |database|
    yield database
  end
end

#get_all_documents_by_key(view, key) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/rdomino/database_collection.rb', line 27

def get_all_documents_by_key(view,key)
  @databases.each do |database|
    database[view].get_all_documents_by_key(key).each do|doc|
      yield database.server, doc
    end
  end
end