Sha256: 7b1f95a003e0631353d1724a3f41073041201a581566c44ab93ca2e6b7f09be0

Contents?: true

Size: 613 Bytes

Versions: 1

Compression:

Stored size: 613 Bytes

Contents

module JsonapiCompliable
  # Rails Integration. Mix this in to ApplicationController.
  #
  # * Mixes in Base
  # * Adds a global around_action (see Base#wrap_context)
  #
  # @see Base#render_jsonapi
  # @see Base#wrap_context
  module Rails
    def self.included(klass)
      klass.class_eval do
        include JsonapiCompliable::Context
        include JsonapiErrorable
        around_action :wrap_context
      end
    end

    def wrap_context
      JsonapiCompliable.with_context(jsonapi_context, action_name.to_sym) do
        yield
      end
    end

    def jsonapi_context
      self
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jsonapi_compliable-1.0.alpha.2 lib/jsonapi_compliable/rails.rb