Module: Kangaroo::Model::OpenObjectOrm
Constant Summary
Constants included from ConditionNormalizer
ConditionNormalizer::CONDITION_OPERATORS, ConditionNormalizer::CONDITION_PATTERN
Instance Method Summary collapse
-
#create_record(attributes, options = {}) ⇒ Number
Create a OpenObject record.
-
#default_get(options = {}) ⇒ Hash
Fetch default attribute values from OpenERP database.
-
#fields_get(options = {}) ⇒ Hash
Retrieve field informations.
-
#read(ids, options = {}) ⇒ Array
Read records and instantiate them.
-
#search(conditions, options = {}) ⇒ Object
Search for records in the OpenERP database.
-
#unlink(ids, options = {}) ⇒ boolean
Remove records.
-
#write_record(ids, attributes, options = {}) ⇒ boolean
Write values to records.
Instance Method Details
#create_record(attributes, options = {}) ⇒ Number
Create a OpenObject record.
76 77 78 |
# File 'lib/kangaroo/model/open_object_orm.rb', line 76 def create_record attributes, = {} remote.create attributes, [:context] end |
#default_get(options = {}) ⇒ Hash
Fetch default attribute values from OpenERP database
87 88 89 90 91 92 93 |
# File 'lib/kangaroo/model/open_object_orm.rb', line 87 def default_get = {} = { :fields => attribute_names }.merge() remote.default_get [:fields], [:context] end |
#fields_get(options = {}) ⇒ Hash
Retrieve field informations
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/kangaroo/model/open_object_orm.rb', line 59 def fields_get = {} = { :fields => attribute_names, :context => {} }.merge() remote.fields_get([:fields], [:context]).map do |key, val| Field.new key, val end end |
#read(ids, options = {}) ⇒ Array
Read records and instantiate them
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/kangaroo/model/open_object_orm.rb', line 40 def read ids, = {} fields = [:fields] fields = attribute_names if [:fields].blank? context = [:context] [].tap do |result| remote.read(ids, fields, context).each do |attributes| position = ids.index(attributes[:id].to_i) result[position] = instantiate attributes, context end end end |
#search(conditions, options = {}) ⇒ Object
Search for records in the OpenERP database
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/kangaroo/model/open_object_orm.rb', line 19 def search conditions, = {} = { :limit => false, :offset => 0 }.merge() remote.search normalize_conditions(conditions), [:offset], [:limit], [:order], [:context], [:count] end |
#unlink(ids, options = {}) ⇒ boolean
Remove records
112 113 114 |
# File 'lib/kangaroo/model/open_object_orm.rb', line 112 def unlink ids, = {} remote.unlink ids, [:context] end |
#write_record(ids, attributes, options = {}) ⇒ boolean
Write values to records
102 103 104 |
# File 'lib/kangaroo/model/open_object_orm.rb', line 102 def write_record ids, attributes, = {} remote.write ids, attributes, [:context] end |