Class: Opencrx::Account::AccountRecord

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/opencrx.rb

Direct Known Subclasses

Contact, Group, LegalEntity, UnspecifiedAccount

Constant Summary collapse

BASEKEY =
"org.opencrx.kernel.account1"

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ AccountRecord

Returns a new instance of AccountRecord.



109
110
111
112
# File 'lib/opencrx.rb', line 109

def initialize(attributes)
  attributes = attributes[key] if attributes.has_key? key
  super attributes
end

Instance Method Details

#keyObject



114
115
116
# File 'lib/opencrx.rb', line 114

def key
  "#{BASEKEY}.#{ActiveSupport::Inflector.demodulize self.class}"
end

#saveObject



118
119
120
121
122
123
124
# File 'lib/opencrx.rb', line 118

def save
  if has_key?('href')
    Opencrx::.put(fetch('href'), xml)
  else
    Opencrx::.post(xml)
  end
end

#xmlObject



126
127
128
# File 'lib/opencrx.rb', line 126

def xml
  __getobj__.except('owner', 'owningUser', 'owningGroup', 'href', 'version').to_xml(root: key)
end