Sha256: 2d358db4ecc2d05e2a0b1c238d5e2898f2ab6a68d6b1dda1c652626e346a424c

Contents?: true

Size: 833 Bytes

Versions: 3

Compression:

Stored size: 833 Bytes

Contents

# frozen_string_literal: true

class Solid::Process
  module Callbacks
    def self.included(subclass)
      subclass.include ActiveSupport::Callbacks

      subclass.define_callbacks(:call, :success, :failure)

      subclass.extend ClassMethods
    end

    module ClassMethods
      def before_call(*filters, &block)
        set_callback(:call, :before, *filters, &block)
      end

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

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

      def after_success(*filters, &block)
        set_callback(:success, :after, *filters, &block)
      end

      def after_failure(*filters, &block)
        set_callback(:failure, :after, *filters, &block)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
solid-process-0.4.0 lib/solid/process/callbacks.rb
solid-process-0.3.0 lib/solid/process/callbacks.rb
solid-process-0.2.0 lib/solid/process/callbacks.rb