Sha256: a9f0304e6a04651f27bb459b99826a2611d610cf0bf14c03f851fd48dd750dd1

Contents?: true

Size: 1017 Bytes

Versions: 5

Compression:

Stored size: 1017 Bytes

Contents

# frozen_string_literal: true

module IIPolicy
  module Callbacks
    extend ActiveSupport::Concern
    include ActiveSupport::Callbacks

    included do
      define_callbacks :all
      define_callbacks :call
    end

    def call_all(action)
      run_callbacks :all do
        super
      end
    end

    def call(action)
      run_callbacks :call do
        super
      end
    end

    class_methods do
      def before_all(*args, &block)
        set_callback(:all, :before, *args, &block)
      end

      def after_all(*args, &block)
        set_callback(:all, :after, *args, &block)
      end

      def around_all(*args, &block)
        set_callback(:all, :around, *args, &block)
      end

      def before_call(*args, &block)
        set_callback(:call, :before, *args, &block)
      end

      def after_call(*args, &block)
        set_callback(:call, :after, *args, &block)
      end

      def around_call(*args, &block)
        set_callback(:call, :around, *args, &block)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ii_policy-2.3.0 lib/ii_policy/callbacks.rb
ii_policy-2.2.2 lib/ii_policy/callbacks.rb
ii_policy-2.2.1 lib/ii_policy/callbacks.rb
ii_policy-2.2.0 lib/ii_policy/callbacks.rb
ii_policy-2.1.0 lib/ii_policy/callbacks.rb