Sha256: 73ff67dade52eaa3fc8d1e9837cbc4ebb156d4cdaa809661ee8a7961e058c37c
Contents?: true
Size: 969 Bytes
Versions: 16
Compression:
Stored size: 969 Bytes
Contents
module Protobuf class Lifecycle class << self def register(event_name, &blk) fail "Lifecycle register must have a block" unless block_given? event_name = normalized_event_name(event_name) ::ActiveSupport::Notifications.subscribe(event_name) do |_name, _start, _finish, _id, args| blk.call(*args) end end alias_method :on, :register def trigger(event_name, *args) event_name = normalized_event_name(event_name) ::ActiveSupport::Notifications.instrument(event_name, args) end replacement = ::ActiveSupport::Notifications ::Protobuf.deprecator.deprecate_methods( self, :register => "#{replacement}.#{replacement.method(:subscribe).name}".to_sym, :trigger => "#{replacement}.#{replacement.method(:instrument).name}".to_sym, ) def normalized_event_name(event_name) event_name.to_s.downcase end end end end
Version data entries
16 entries across 16 versions & 2 rubygems