Sha256: a414f1720e90379c8c2c0011a17128aaa79eb83f43be5a7291051ee4fd8e2658
Contents?: true
Size: 960 Bytes
Versions: 9
Compression:
Stored size: 960 Bytes
Contents
module Protobuf class Lifecycle class << self def register(event_name) 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| yield(*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
9 entries across 9 versions & 1 rubygems