Skip to content

v0.1.0

Compare
Choose a tag to compare
@lgebhardt lgebhardt released this 23 Jan 20:06
· 1484 commits to master since this release

This release adds callbacks to resources based on ActiveSupport::Callbacks. See the README for more details.

This release breaks the existing callback scheme for JSONAPI:: OperationsProcessor. The old callbacks have been replaced with the callback system based on ActiveSupport::Callbacks.

Conversion should be simple. Here's an example. This:

class ApprovingOperationsProcessor < JSONAPI::ActiveRecordOperationsProcessor

  def before_operation(context, operation)
    operation.resource_klass.approve_operation(context, operation)
  end
end

will need to be converted to this:

class ApprovingOperationsProcessor < JSONAPI::ActiveRecordOperationsProcessor
  before_operation :approve_operation

  def approve_operation
    @operation.resource_klass.approve_operation(@context, @operation)
  end
end

A key difference is that the parameters are no longer passed in to the callback. Instead they are accessible as instance variables on the OperationsProcessor. You also have access to @result, @results, and @operations instance variables.

In addition there are callbacks for the set of operations as well as the individual operations. And all callbacks support before, after and around.