Class: Kangaroo::Util::Database

Inherits:
Object
  • Object
show all
Defined in:
lib/kangaroo/util/database.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, name, user, password) ⇒ Database

Initialize a new OpenERP database configuration

Parameters:

  • client

    A Client instance

  • name

    Database name to configure

  • user

    Username

  • password

    Password



12
13
14
# File 'lib/kangaroo/util/database.rb', line 12

def initialize client, name, user, password
  @client, @db_name, @user, @password = client, name, user, password
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



4
5
6
# File 'lib/kangaroo/util/database.rb', line 4

def client
  @client
end

#db_nameObject

Returns the value of attribute db_name.



4
5
6
# File 'lib/kangaroo/util/database.rb', line 4

def db_name
  @db_name
end

#passwordObject

Returns the value of attribute password.



4
5
6
# File 'lib/kangaroo/util/database.rb', line 4

def password
  @password
end

#userObject

Returns the value of attribute user.



4
5
6
# File 'lib/kangaroo/util/database.rb', line 4

def user
  @user
end

#user_idObject

Returns the value of attribute user_id.



4
5
6
# File 'lib/kangaroo/util/database.rb', line 4

def user_id
  @user_id
end

Instance Method Details

#commonObject

Access to the Common Proxy

Returns:

  • common service proxy



34
35
36
# File 'lib/kangaroo/util/database.rb', line 34

def common
  client.common
end

#dbObject

Access to the Database Proxy

Returns:

  • database service proxy



27
28
29
# File 'lib/kangaroo/util/database.rb', line 27

def db
  client.db
end

#logged_in?Boolean

Test of the current user is logged in

Returns:

  • (Boolean)

    true/false



69
70
71
# File 'lib/kangaroo/util/database.rb', line 69

def logged_in?
  !!user_id
end

#loginObject

Login the current user, unless logged in.

Returns:

  • true/false



85
86
87
88
89
# File 'lib/kangaroo/util/database.rb', line 85

def 
  logged_in? || login!
rescue
  false
end

#login!Object

Login the current user

Returns:

  • true/false



76
77
78
79
80
# File 'lib/kangaroo/util/database.rb', line 76

def login!
  @user_id = common. db_name, user, password

  logged_in?
end

#object(model_name) ⇒ Object

Access to the Object Proxy

Returns:

  • object service proxy



48
49
50
# File 'lib/kangaroo/util/database.rb', line 48

def object model_name
  Proxy::Object.new client.object_service, db_name, user_id, password, model_name
end

#reportObject

Access to the Report Proxy

Returns:

  • report service proxy



62
63
64
# File 'lib/kangaroo/util/database.rb', line 62

def report
  @report_proxy ||= Proxy::Report.new client.report_service, db_name, user_id, password
end

#superadmin(super_password) ⇒ Object

Access to the Superadmin Proxy

Parameters:

  • super_password

    superadmin password

Returns:

  • superadmin service proxy



20
21
22
# File 'lib/kangaroo/util/database.rb', line 20

def superadmin super_password
  client.superadmin super_password
end

#wizardObject

Access to the Wizard Proxy

Returns:

  • wizard service proxy



55
56
57
# File 'lib/kangaroo/util/database.rb', line 55

def wizard
  @wizard_proxy ||= Proxy::Wizard.new client.wizard_service, db_name, user_id, password
end

#workflowObject

Access to the Workflow Proxy

Returns:

  • workflow service proxy



41
42
43
# File 'lib/kangaroo/util/database.rb', line 41

def workflow
  @workflow_proxy ||= Proxy::Workflow.new client.object_service, db_name, user_id, password
end