Sha256: 2fffef3ee564da7bf4948ed449f4318a1867be2072813506cb683511d05f981a

Contents?: true

Size: 350 Bytes

Versions: 109

Compression:

Stored size: 350 Bytes

Contents

module Pageflow
  class Hooks
    def initialize
      @subscribers = Hash.new do |hash, key|
        hash[key] = []
      end
    end

    def on(event, subscriber)
      @subscribers[event] << subscriber
    end

    def invoke(event, *args)
      @subscribers[event].each do |subscriber|
        subscriber.call(*args)
      end
    end
  end
end

Version data entries

109 entries across 109 versions & 1 rubygems

Version Path
pageflow-17.0.4 lib/pageflow/hooks.rb
pageflow-17.0.3 lib/pageflow/hooks.rb
pageflow-17.0.2 lib/pageflow/hooks.rb
pageflow-17.0.1 lib/pageflow/hooks.rb
pageflow-17.0.0 lib/pageflow/hooks.rb
pageflow-16.2.0 lib/pageflow/hooks.rb
pageflow-16.1.0 lib/pageflow/hooks.rb
pageflow-16.0.0 lib/pageflow/hooks.rb
pageflow-15.8.0 lib/pageflow/hooks.rb
pageflow-14.5.2 lib/pageflow/hooks.rb
pageflow-15.7.1 lib/pageflow/hooks.rb
pageflow-15.7.0 lib/pageflow/hooks.rb
pageflow-15.6.1 lib/pageflow/hooks.rb
pageflow-15.6.0 lib/pageflow/hooks.rb
pageflow-15.5.0 lib/pageflow/hooks.rb
pageflow-15.4.0 lib/pageflow/hooks.rb
pageflow-15.3.0 lib/pageflow/hooks.rb
pageflow-15.2.2 lib/pageflow/hooks.rb
pageflow-15.2.1 lib/pageflow/hooks.rb
pageflow-15.2.0 lib/pageflow/hooks.rb