Sha256: da4d812656a3c2e7690a7ea7ecdf66851538fd0fbb07ff17cc45c6f1d353ec4c

Contents?: true

Size: 586 Bytes

Versions: 2

Compression:

Stored size: 586 Bytes

Contents

module Graphiti
  # 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 Graphiti::Context
        include JsonapiErrorable
        around_action :wrap_context
      end
    end

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

    def jsonapi_context
      self
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
graphiti-1.0.alpha.1 lib/graphiti/rails.rb
graphiti-rb-1.0.alpha.1 lib/graphiti/rails.rb