Sha256: fd4ec876ee63011ed2400fe8c304e2b72f379a6c3b73b436ad2c5adfe8eb0f54

Contents?: true

Size: 582 Bytes

Versions: 90

Compression:

Stored size: 582 Bytes

Contents

module ActiveAdmin

  class EventDispatcher
    def initialize
      @events = {}
    end

    def clear_all_subscribers!
      @events = {}
    end

    def subscribe(*event_names, &block)
      event_names.each do |event|
        @events[event] ||= []
        @events[event] << block
      end
    end

    def subscribers(event)
      @events[event] || []
    end

    def dispatch(event, *args)
      subscribers(event).each do |subscriber|
        subscriber.call(*args)
      end
    end
  end

  # ActiveAdmin::Event is set to a dispatcher
  Event = EventDispatcher.new

end

Version data entries

90 entries across 90 versions & 7 rubygems

Version Path
yousty-activeadmin-1.0.17.pre lib/active_admin/event.rb
yousty-activeadmin-1.0.16.pre lib/active_admin/event.rb
yousty-activeadmin-1.0.15.pre lib/active_admin/event.rb
yousty-activeadmin-1.0.14.pre lib/active_admin/event.rb
yousty-activeadmin-1.0.13.pre lib/active_admin/event.rb
yousty-activeadmin-1.0.12.pre lib/active_admin/event.rb
yousty-activeadmin-1.0.11.pre lib/active_admin/event.rb
yousty-activeadmin-1.0.10.pre lib/active_admin/event.rb
yousty-activeadmin-1.0.9.pre lib/active_admin/event.rb
yousty-activeadmin-1.0.8.pre lib/active_admin/event.rb
activeadmin-1.0.0.pre1 lib/active_admin/event.rb
yousty-activeadmin-1.0.7.pre lib/active_admin/event.rb
yousty-activeadmin-1.0.6.pre lib/active_admin/event.rb
yousty-activeadmin-1.0.5.pre lib/active_admin/event.rb
activeadmin-0.6.6 lib/active_admin/event.rb
activeadmin-0.6.5 lib/active_admin/event.rb
activeadmin-0.6.4 lib/active_admin/event.rb
yousty-activeadmin-1.0.4.pre lib/active_admin/event.rb
yousty-activeadmin-1.0.3.pre lib/active_admin/event.rb
active_administration-0.0.3 lib/active_admin/event.rb