Class: JSONAPI::RemoveHasOneAssociationOperation
- Defined in:
- lib/jsonapi/operation.rb
Instance Attribute Summary collapse
-
#association_type ⇒ Object
readonly
Returns the value of attribute association_type.
-
#resource_id ⇒ Object
readonly
Returns the value of attribute resource_id.
Attributes inherited from Operation
Instance Method Summary collapse
- #apply(context) ⇒ Object
-
#initialize(resource_klass, resource_id, association_type) ⇒ RemoveHasOneAssociationOperation
constructor
A new instance of RemoveHasOneAssociationOperation.
Constructor Details
#initialize(resource_klass, resource_id, association_type) ⇒ RemoveHasOneAssociationOperation
Returns a new instance of RemoveHasOneAssociationOperation.
137 138 139 140 141 |
# File 'lib/jsonapi/operation.rb', line 137 def initialize(resource_klass, resource_id, association_type) @resource_id = resource_id @association_type = association_type super(resource_klass) end |
Instance Attribute Details
#association_type ⇒ Object (readonly)
Returns the value of attribute association_type.
135 136 137 |
# File 'lib/jsonapi/operation.rb', line 135 def association_type @association_type end |
#resource_id ⇒ Object (readonly)
Returns the value of attribute resource_id.
135 136 137 |
# File 'lib/jsonapi/operation.rb', line 135 def resource_id @resource_id end |
Instance Method Details
#apply(context) ⇒ Object
143 144 145 146 147 148 149 |
# File 'lib/jsonapi/operation.rb', line 143 def apply(context) resource = @resource_klass.find_by_key(@resource_id, context) resource.remove_has_one_link(@association_type, context) resource.save return JSONAPI::OperationResult.new(:no_content) end |