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
#options, #resource_klass, #transactional
Instance Method Summary collapse
- #apply ⇒ Object
-
#initialize(resource_klass, options) ⇒ RemoveHasOneAssociationOperation
constructor
A new instance of RemoveHasOneAssociationOperation.
Constructor Details
#initialize(resource_klass, options) ⇒ RemoveHasOneAssociationOperation
Returns a new instance of RemoveHasOneAssociationOperation.
298 299 300 301 302 |
# File 'lib/jsonapi/operation.rb', line 298 def initialize(resource_klass, ) @resource_id = .fetch(:resource_id) @association_type = .fetch(:association_type).to_sym super(resource_klass, ) end |
Instance Attribute Details
#association_type ⇒ Object (readonly)
Returns the value of attribute association_type.
296 297 298 |
# File 'lib/jsonapi/operation.rb', line 296 def association_type @association_type end |
#resource_id ⇒ Object (readonly)
Returns the value of attribute resource_id.
296 297 298 |
# File 'lib/jsonapi/operation.rb', line 296 def resource_id @resource_id end |
Instance Method Details
#apply ⇒ Object
304 305 306 307 308 309 |
# File 'lib/jsonapi/operation.rb', line 304 def apply resource = @resource_klass.find_by_key(@resource_id, context: @context) result = resource.remove_has_one_link(@association_type) return JSONAPI::OperationResult.new(result == :completed ? :no_content : :accepted) end |