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
lalala-4.0.0.dev.126 vendor/deps/active_admin/lib/active_admin/event.rb
lalala-4.0.0.dev.125 vendor/deps/active_admin/lib/active_admin/event.rb
lalala-4.0.0.dev.124 vendor/deps/active_admin/lib/active_admin/event.rb
lalala-4.0.0.dev.123 vendor/deps/active_admin/lib/active_admin/event.rb
lalala-4.0.0.dev.118 vendor/deps/active_admin/lib/active_admin/event.rb
lalala-4.0.0.dev.116 vendor/deps/active_admin/lib/active_admin/event.rb
lalala-4.0.0.dev.114 vendor/deps/active_admin/lib/active_admin/event.rb
lalala-4.0.0.dev.113 vendor/deps/active_admin/lib/active_admin/event.rb
lalala-4.0.0.dev.111 vendor/deps/active_admin/lib/active_admin/event.rb
lalala-4.0.0.dev.109 vendor/deps/active_admin/lib/active_admin/event.rb
lalala-4.0.0.dev.107 vendor/deps/active_admin/lib/active_admin/event.rb
lalala-4.0.0.dev.94 vendor/deps/active_admin/lib/active_admin/event.rb
lalala-4.0.0.dev.92 vendor/deps/active_admin/lib/active_admin/event.rb
lalala-4.0.0.dev.90 vendor/deps/active_admin/lib/active_admin/event.rb
lalala-4.0.0.dev.84 vendor/deps/active_admin/lib/active_admin/event.rb
lalala-4.0.0.dev.80 vendor/deps/active_admin/lib/active_admin/event.rb
lalala-4.0.0.dev.79 vendor/deps/active_admin/lib/active_admin/event.rb
lalala-4.0.0.dev.78 vendor/deps/active_admin/lib/active_admin/event.rb
lalala-4.0.0.dev.77 vendor/deps/active_admin/lib/active_admin/event.rb
lalala-4.0.0.dev.74 vendor/deps/active_admin/lib/active_admin/event.rb