Module: CiviCrm::Actions::Update

Included in:
BaseResource
Defined in:
lib/civicrm/actions/update.rb

Instance Method Summary collapse

Instance Method Details

#saveObject



22
23
24
# File 'lib/civicrm/actions/update.rb', line 22

def save
  update()
end

#update(attrs = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/civicrm/actions/update.rb', line 4

def update(attrs = {})
  attrs = attrs.reverse_merge(changes.transform_values(&:last))

  params = {
    'entity' => self.class.entity_class_name,
    'action' => 'create',
    'id' => id
  }.merge(attrs)

  response = CiviCrm::Client.request(:post, params)
  refresh_from(response.first.to_hash)

  @previously_changed = changes
  @changed_attributes.clear if @changed_attributes

  self
end