Module: Unit::ResourceOperations::Save

Included in:
AchCounterparty, DepositAccount, IndividualCustomer, IndividualDebitCard
Defined in:
lib/unit-ruby/util/resource_operations.rb

Instance Method Summary collapse

Instance Method Details

#save(attributes) ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/unit-ruby/util/resource_operations.rb', line 66

def save(attributes)
  resource = self.class.new(attributes.except(:id))
  updated_resource = self.class.connection.patch(
    self.class.resource_path(id),
    {
      data: {
        type: resource_type,
        attributes: resource.as_json_api.slice(*resource.dirty_attributes)
      }
    }
  )
  update_resource_from_json_api(updated_resource)
end