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.
167 168 169 170 171 |
# File 'lib/jsonapi/operation.rb', line 167 def initialize(resource_klass, resource_id, association_type) @resource_id = resource_id @association_type = association_type.to_sym super(resource_klass) end |
Instance Attribute Details
#association_type ⇒ Object (readonly)
Returns the value of attribute association_type.
165 166 167 |
# File 'lib/jsonapi/operation.rb', line 165 def association_type @association_type end |
#resource_id ⇒ Object (readonly)
Returns the value of attribute resource_id.
165 166 167 |
# File 'lib/jsonapi/operation.rb', line 165 def resource_id @resource_id end |
Instance Method Details
#apply(context) ⇒ Object
173 174 175 176 177 178 |
# File 'lib/jsonapi/operation.rb', line 173 def apply(context) resource = @resource_klass.find_by_key(@resource_id, context: context) resource.remove_has_one_link(@association_type) return JSONAPI::OperationResult.new(:no_content) end |