Class: Rdomino::DatabaseLibrary

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(db) ⇒ DatabaseLibrary

Returns a new instance of DatabaseLibrary.



8
9
10
11
12
13
# File 'lib/rdomino/database_library.rb', line 8

def initialize(db)
  @database = Database.new(db)
  @view = database.get_view("DS2000/all")
  @databases = {}
  @views = {}
end

Instance Attribute Details

#databaseObject (readonly)

Returns the value of attribute database.



6
7
8
# File 'lib/rdomino/database_library.rb', line 6

def database
  @database
end

#viewObject (readonly)

Returns the value of attribute view.



6
7
8
# File 'lib/rdomino/database_library.rb', line 6

def view
  @view
end

Instance Method Details

#find(dbkey, key = nil) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rdomino/database_library.rb', line 15

def find(dbkey,key=nil)
  unless @databases[dbkey]
    doc = view.get_document_by_key(dbkey)
    @databases[dbkey] = Database.new(database.server,doc.getItemValue("pathname")[0])
  end
  if key 
    unless @views[dbkey]
      @views[dbkey] = @databases[dbkey].get_view("(DirSync-G2)")
      puts "| init view in #{dbkey}"
    end
    @views[dbkey].get_document_by_key(key)
  else
    @databases[dbkey]
  end
  #Openbyreplicaid(byval server as string, byval replicaid as string) as variant
end