module OpenObject::ClassMethods
extended class methods
Public Instance Methods
Builds OpenObject
connection @param user_context [Hash] the hash MUST contain keys and values for ‘dbname`, `uid`, `password` @return [XMLRPC::Client::Proxy]
# File lib/open_object.rb, line 139 def connection(user_context) XMLRPC::Client.new(OpenObject.host, OpenObject.object, OpenObject.port) .proxy(nil, user_context[:dbname], user_context[:uid], user_context[:pwd]) end
OpenObject’s create (see search
)
# File lib/open_object.rb, line 163 def create(user_context, args = []) OpenObject.rescue_xmlrpc_fault do result = connection(user_context).execute(open_object_model, 'create', args) OpenObject.logger.debug("OpenObject.create with #{args}") OpenObject.logger.debug("Responded with : #{result}") BackendResponse.new(success: true, errors: nil, content: result) end end
@return String : value of the open_object model
# File lib/open_object.rb, line 132 def open_object_model @open_object_model ||= self.name.underscore end
OpenObject’s read (see search
) @param ids [Array<Fixnum>] the OpenObject’s ids @param fields [Array<String>] see OpenObject’s documentation
# File lib/open_object.rb, line 176 def read(user_context, ids, fields = []) OpenObject.rescue_xmlrpc_fault do result = connection(user_context).execute(open_object_model, 'read', ids, fields) OpenObject.logger.debug("OpenObject.read ids : #{ids} fields : #{fields}") OpenObject.logger.debug("Responded with : #{result}") BackendResponse.new(success: true, errors: nil, content: result) end end
OpenObject
search query @param use_context (see connection
) @param args [Array] the OpenObject
method’s args see OpenObject’s documentation @param offset [Fixnum] see OpenObject’s documentation @param limit [Fixnum] see OpenObject’s documentation @param order [String] see OpenObject’s documentation @return [BackendResponse] see OpenObject’s documentation
# File lib/open_object.rb, line 151 def search(user_context, args = [], offset: 0, limit: 0, order: nil) open_object_request_parameters = [offset, limit, order].compact OpenObject.rescue_xmlrpc_fault do result = connection(user_context).execute(open_object_model, 'search', args, *open_object_request_parameters ) OpenObject.logger.debug("OpenObject.search with #{args}") OpenObject.logger.debug("Responded with : #{result}") BackendResponse.new(success: true, errors: nil, content: result) end end
To set model name in case it is not the humanized class name @param model : String
# File lib/open_object.rb, line 125 def set_open_object_model(model = String.new) @open_object_model = model end
OpenObject’s unlink ( see read
)
# File lib/open_object.rb, line 199 def unlink(user_context,ids) OpenObject.rescue_xmlrpc_fault do result = connection(user_context).execute(open_object_model, 'unlink', ids) OpenObject.logger.debug("OpenObject.unlink ids : #{ids}") OpenObject.logger.debug("Responded with : #{result}") BackendResponse.new( success: result, errors: nil) end end
OpenObject’s write (see read
) (see create
)
# File lib/open_object.rb, line 188 def write(user_context, ids, args) OpenObject.rescue_xmlrpc_fault do result = connection(user_context).execute(open_object_model, 'write', ids, args) OpenObject.logger.debug("OpenObject.write ids : #{ids} args : #{args}") OpenObject.logger.debug("Responded with : #{result}") BackendResponse.new( success: result, errors: nil) end end