Class: OoorProxy
- Inherits:
- BasicObject
- Defined in:
- lib/cucumber/lib/utils/ooor_utils.rb
Instance Attribute Summary collapse
-
#log ⇒ Object
readonly
Delegate to OOOR except the OERPScenario methods to manage the connections.
Instance Method Summary collapse
- #create_database(params) ⇒ Object
-
#initialize(log) ⇒ OoorProxy
constructor
A new instance of OoorProxy.
- #login(params) ⇒ Object
-
#open_connection(params) ⇒ Object
read the base.conf file to set all the parameter to begin an xml rpc session with openerp you can override any of the parameters.
Constructor Details
#initialize(log) ⇒ OoorProxy
Returns a new instance of OoorProxy.
77 78 79 |
# File 'lib/cucumber/lib/utils/ooor_utils.rb', line 77 def initialize(log) @log = log end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object (protected)
130 131 132 |
# File 'lib/cucumber/lib/utils/ooor_utils.rb', line 130 def method_missing(name, *args, &block) @ooor.send(name, *args, &block) end |
Instance Attribute Details
#log ⇒ Object (readonly)
Delegate to OOOR except the OERPScenario methods to manage the connections
75 76 77 |
# File 'lib/cucumber/lib/utils/ooor_utils.rb', line 75 def log @log end |
Instance Method Details
#create_database(params) ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/cucumber/lib/utils/ooor_utils.rb', line 117 def create_database(params) log.info("Creating a new database") begin @ooor = Ooor.new(:url => xmlrpc_url(params)) @ooor.create(ooor_config[:pwd], params[:dbname], false, 'en_US', params[:pwd]) @ooor.load_models(false) rescue RuntimeError log.fatal("ERROR : Cannot create database") raise 'Cannot create database' end self end |
#login(params) ⇒ Object
86 87 88 |
# File 'lib/cucumber/lib/utils/ooor_utils.rb', line 86 def login(params) @ooor.global_login(params[:user], params[:pwd]) end |
#open_connection(params) ⇒ Object
read the base.conf file to set all the parameter to begin an xml rpc session with openerp you can override any of the parameters
102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/cucumber/lib/utils/ooor_utils.rb', line 102 def open_connection(params) if @ooor login(params) else begin @ooor = init_ooor_connection(params) rescue RuntimeError #We catch RuntimeError because ooor doesn't give the error name. #we deduce in that case that the database doesn't exist and we have to create it. log.warn("No database, try to create it") create_database_with_ooor(params) end end self end |