Class: Ooor::Service
- Inherits:
-
Object
- Object
- Ooor::Service
- Defined in:
- lib/ooor/services.rb
Direct Known Subclasses
Class Method Summary collapse
-
.define_service(service, methods) ⇒ Object
using define_method provides handy autocompletion.
Instance Method Summary collapse
-
#initialize(session) ⇒ Service
constructor
A new instance of Service.
Constructor Details
#initialize(session) ⇒ Service
Returns a new instance of Service.
13 14 15 |
# File 'lib/ooor/services.rb', line 13 def initialize(session) @session = session end |
Class Method Details
.define_service(service, methods) ⇒ Object
using define_method provides handy autocompletion
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/ooor/services.rb', line 18 def self.define_service(service, methods) methods.each do |meth| self.instance_eval do define_method meth do |*args| if @session.odoo_serie > 7 json_conn = @session.get_client(:json, "#{@session.base_jsonrpc2_url}") json_conn.oe_service(@session.web_session, service, nil, meth, *args) else # via XMLRPC on v7: endpoint = @session.get_client(:xml, "#{@session.base_url}/#{service.to_s.gsub('ooor_alias_', '')}") endpoint.call(meth.gsub('ooor_alias_', ''), *args) end end end end end |