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-15.1.2 lib/pageflow/hooks.rb
pageflow-15.1.1 lib/pageflow/hooks.rb
pageflow-15.1.0 lib/pageflow/hooks.rb
pageflow-15.1.0.rc0 lib/pageflow/hooks.rb
pageflow-15.1.0.beta6 lib/pageflow/hooks.rb
pageflow-15.1.0.beta5 lib/pageflow/hooks.rb
pageflow-15.1.0.beta4 lib/pageflow/hooks.rb
pageflow-15.1.0.beta3 lib/pageflow/hooks.rb
pageflow-15.1.0.beta2 lib/pageflow/hooks.rb
pageflow-15.1.0.beta1 lib/pageflow/hooks.rb
pageflow-15.0.2 lib/pageflow/hooks.rb
pageflow-15.0.1 lib/pageflow/hooks.rb
pageflow-15.0.0 lib/pageflow/hooks.rb
pageflow-14.5.1 lib/pageflow/hooks.rb
pageflow-14.5.0 lib/pageflow/hooks.rb
pageflow-15.0.0.rc2 lib/pageflow/hooks.rb
pageflow-15.0.0.rc1 lib/pageflow/hooks.rb
pageflow-15.0.0.beta4 lib/pageflow/hooks.rb
pageflow-15.0.0.beta3 lib/pageflow/hooks.rb
pageflow-14.4.0 lib/pageflow/hooks.rb