Class: Kangaroo::Model::Base

Inherits:
Object
  • Object
show all
Extended by:
ActiveModel::Callbacks, Finder, OpenObjectOrm
Includes:
Attributes, DefaultAttributes, Inspector, Persistence, RemoteExecute
Defined in:
lib/kangaroo/model/base.rb

Constant Summary

Constants included from ConditionNormalizer

ConditionNormalizer::CONDITION_OPERATORS, ConditionNormalizer::CONDITION_PATTERN

Constants included from Finder

Finder::RELATION_DELEGATES

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from OpenObjectOrm

create_record, default_get, fields_get, read, search, unlink, write_record

Methods included from Finder

all, count, exists?, find, first, last

Methods included from RemoteExecute

#call

Methods included from Persistence

#destroy, #destroyed?, #new_record?, #persisted?, #reload, #save, #save!

Methods included from Attributes

#attributes, #attributes=, #freeze, #read_attribute, #write_attribute

Constructor Details

#initialize(attributes = {}) ⇒ Base

Initialize a new object, and set attributes

Parameters:

  • attributes (Hash) (defaults to: {})


34
35
36
37
38
39
40
# File 'lib/kangaroo/model/base.rb', line 34

def initialize attributes = {}
  @attributes = {}

  _run_initialize_callbacks do
    self.attributes = attributes
  end
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



29
30
31
# File 'lib/kangaroo/model/base.rb', line 29

def id
  @id
end

Class Method Details

.fieldsObject



49
50
51
# File 'lib/kangaroo/model/base.rb', line 49

def fields
  @fields ||= fields_get
end

.namespaceObject



53
54
55
# File 'lib/kangaroo/model/base.rb', line 53

def namespace
  ("::" + name.match(/^(?:\:\:)?([^\:]+)/)[1]).constantize
end

.oo_nameObject

Return this models OpenObject name



58
59
60
# File 'lib/kangaroo/model/base.rb', line 58

def oo_name
  namespace.ruby_to_oo self.name
end

.remoteObject

Send method calls via xmlrpc to OpenERP



64
65
66
# File 'lib/kangaroo/model/base.rb', line 64

def remote
  @remote ||= database.object oo_name
end

Instance Method Details

#remoteObject

Send method calls via xmlrpc to OpenERP



44
45
46
# File 'lib/kangaroo/model/base.rb', line 44

def remote
  self.class.remote
end