module OpenObject::ClassMethods

extended class methods

Public Instance Methods

connection(user_context) click to toggle source

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
create(user_context, args = []) click to toggle source

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
open_object_model() click to toggle source

@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
read(user_context, ids, fields = []) click to toggle source

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
set_open_object_model(model = String.new) click to toggle source

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
write(user_context, ids, args) click to toggle source

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