Class: JSONAPI::Realizer::Action::Update
- Inherits:
-
JSONAPI::Realizer::Action
- Object
- JSONAPI::Realizer::Action
- JSONAPI::Realizer::Action::Update
- Defined in:
- lib/jsonapi/realizer/action/update.rb
Instance Attribute Summary collapse
-
#resource ⇒ Object
Returns the value of attribute resource.
Attributes inherited from JSONAPI::Realizer::Action
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(payload:, headers:) ⇒ Update
constructor
A new instance of Update.
- #model ⇒ Object
Constructor Details
#initialize(payload:, headers:) ⇒ Update
Returns a new instance of Update.
7 8 9 10 11 |
# File 'lib/jsonapi/realizer/action/update.rb', line 7 def initialize(payload:, headers:) @payload = payload @headers = headers @resource = resource_class.new(adapter.find_via_call(relation, id)) end |
Instance Attribute Details
#resource ⇒ Object
Returns the value of attribute resource.
5 6 7 |
# File 'lib/jsonapi/realizer/action/update.rb', line 5 def resource @resource end |
Instance Method Details
#call ⇒ Object
13 14 15 16 17 |
# File 'lib/jsonapi/realizer/action/update.rb', line 13 def call adapter.assign_attributes_via_call(resource.model, attributes) adapter.assign_relationships_via_call(resource.model, relationships) adapter.update_via_call(resource.model) end |
#model ⇒ Object
19 20 21 |
# File 'lib/jsonapi/realizer/action/update.rb', line 19 def model resource.model end |