Class: Persist

Inherits:
Object
  • Object
show all
Includes:
BDBXML, BDBXMLJE, Singleton
Defined in:
lib/models/persist.rb

Constant Summary

Constants included from BDBXMLJE

BDBXMLJE::DB_NAME, BDBXMLJE::DB_ROOT

Constants included from BDBXML

BDBXML::DB_NAME, BDBXML::DB_ROOT

Instance Method Summary collapse

Methods included from BDBXMLJE

#create_doc, #create_key_and_doc, #find, #read_doc, #replace_doc, #setup_env

Methods included from BDBXML

#clean_env, #close_env, #create_doc, #create_key_and_doc, #find, #read_doc, #replace_doc, #setup_env

Constructor Details

#initializePersist

Returns a new instance of Persist.



18
19
20
# File 'lib/models/persist.rb', line 18

def initialize
  setup_env
end

Instance Method Details

#get(key) ⇒ Object



34
35
36
# File 'lib/models/persist.rb', line 34

def get(key)
  read_doc(key)
end

#get!(key, request) ⇒ Object

get with the insistence the document will be there if not then create it



40
41
42
43
44
45
46
47
48
49
# File 'lib/models/persist.rb', line 40

def get!(key,request)
  result=""
  begin
    result = read_doc(key)
  rescue Exception => e #document not found
    create_doc(request,key)
    result = read_doc(key)
  end
  return result
end

#put(key, request) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/models/persist.rb', line 22

def put(key,request)
  begin
    if (key == 'UUID') then
      key = UUID.new
      create_doc(request,key)
    else
      replace_doc(request,key)
    end
    key
  end
end