Sha256: 0b0506f623707436738e79fb5d371e329c6316871571c725f778378e8ba59957

Contents?: true

Size: 677 Bytes

Versions: 1

Compression:

Stored size: 677 Bytes

Contents

module DispatchRider
  module Callbacks
    class Storage

      def initialize
        @callbacks = {}
      end

      def before(event, block_param = nil, &block)
        add_callback :before, event, block_param, &block
      end

      def after(event, block_param = nil, &block)
        add_callback :after, event, block_param, &block
      end

      def for(modifier, event)
        @callbacks[[modifier, event]] || []
      end

      private

      def add_callback(modifier, event, block_param = nil, &block)
        block = block || block_param
        @callbacks[[modifier, event]] ||= []
        @callbacks[[modifier, event]] << block
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dispatch-rider-0.1.0 lib/dispatch-rider/callbacks/storage.rb