Sha256: 113054733478bb76a1ac07e58ebb709175c2a148cf3650e53deab4a847447d73

Contents?: true

Size: 551 Bytes

Versions: 1

Compression:

Stored size: 551 Bytes

Contents

module Smooth
  class Event < ActiveSupport::Notifications::Event

    def self.provider
      ActiveSupport::Notifications
    end

    def payload
      hash = super
      hash && hash.to_mash
    end

    module Adapter
      def track_event *args, &block
        Smooth::Event.provider.send(:instrument, *args)
      end

      def subscribe_to event_name, &block
        Smooth::Event.provider.subscribe(event_name) do |*args|
          block.call(Smooth::Event.new(*args), event_name)
        end
      end
    end

    extend Adapter
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
smooth-2.0.1 lib/smooth/event.rb