Sha256: 4f0bcdc454ed31d432547f493d803072b77bd72de641f7e18beb01006847459d

Contents?: true

Size: 1.29 KB

Versions: 26

Compression:

Stored size: 1.29 KB

Contents

module Skylight
  # Ensure the version of AS:N being used is recent enough
  begin
    # Attempt to reference an internal class only present in the new AS::Notifications
    ActiveSupport::Notifications::Fanout::Subscribers
  rescue NameError

    # The things we do...
    class ::ActiveSupport::Notifications::Fanout
      attr_reader :subscribers

      class Subscriber
        attr_reader :pattern, :delegate
      end
    end

    notifier = ActiveSupport::Notifications.notifier

    # If the class is missing, require our vendored AS::N
    require 'skylight/vendor/active_support/notifications'

    if notifier.subscribers.respond_to?(:each)
      notifier.subscribers.each do |sub|
        pattern  = sub.respond_to?(:pattern)  && sub.pattern
        delegate = sub.respond_to?(:delegate) && sub.delegate

        if pattern && delegate
          ActiveSupport::Notifications.subscribe(pattern, delegate)
        end
      end
    end
  end
end

if defined?(ActiveSupport::Notifications::Fanout::Subscribers::Evented)
  # Handle early RCs of rails 4.0
  class ActiveSupport::Notifications::Fanout::Subscribers::Evented
    unless method_defined?(:publish)
      def publish(name, *args)
        if @delegate.respond_to?(:publish)
          @delegate.publish name, *args
        end
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
skylight-0.3.10 lib/skylight/compat.rb
skylight-0.3.8 lib/skylight/compat.rb
skylight-0.3.7 lib/skylight/compat.rb
skylight-0.3.6 lib/skylight/compat.rb
skylight-0.3.3 lib/skylight/compat.rb
skylight-0.3.2 lib/skylight/compat.rb
skylight-0.3.1 lib/skylight/compat.rb
skylight-0.3.0 lib/skylight/compat.rb
skylight-0.2.7 lib/skylight/compat.rb
skylight-0.2.6 lib/skylight/compat.rb
skylight-0.3.0.rc.6 lib/skylight/compat.rb
skylight-0.2.5 lib/skylight/compat.rb
skylight-0.2.4 lib/skylight/compat.rb
skylight-0.3.0.rc.5 lib/skylight/compat.rb
skylight-0.3.0.rc.4 lib/skylight/compat.rb
skylight-0.3.0.rc.3 lib/skylight/compat.rb
skylight-0.2.3 lib/skylight/compat.rb
skylight-0.2.2 lib/skylight/compat.rb
skylight-0.2.1 lib/skylight/compat.rb
skylight-0.2.0 lib/skylight/compat.rb