Sha256: 6eba6d4ed515b643a2a9a794dcf6c821dd4d2a875027b61c90d51213e6ec3b09

Contents?: true

Size: 997 Bytes

Versions: 1

Compression:

Stored size: 997 Bytes

Contents

# frozen_string_literal: true

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

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

      subclass.extend ClassMethods
    end

    module ClassMethods
      def after_success(*args, &block)
        options = args.extract_options!
        options = options.dup
        options[:prepend] = true

        set_callback(:success, :after, *args, options, &block)
      end

      def after_failure(*args, &block)
        options = args.extract_options!
        options = options.dup
        options[:prepend] = true

        set_callback(:failure, :after, *args, options, &block)
      end

      def after_output(*args, &block)
        options = args.extract_options!
        options = options.dup
        options[:prepend] = true

        set_callback(:output, :after, *args, options, &block)
      end

      alias_method :after_result, :after_output
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
solid-process-0.1.0 lib/solid/process/callbacks.rb