Class: Datadog::Contrib::ActiveSupport::Notifications::Subscription::Callbacks
- Inherits:
-
Object
- Object
- Datadog::Contrib::ActiveSupport::Notifications::Subscription::Callbacks
- Defined in:
- lib/ddtrace/contrib/active_support/notifications/subscription.rb
Overview
Wrapper for subscription callbacks
Instance Attribute Summary collapse
-
#blocks ⇒ Object
readonly
Returns the value of attribute blocks.
Instance Method Summary collapse
- #add(key, &block) ⇒ Object
-
#initialize ⇒ Callbacks
constructor
A new instance of Callbacks.
- #run(event, key, *args) ⇒ Object
Constructor Details
#initialize ⇒ Callbacks
Returns a new instance of Callbacks.
129 130 131 |
# File 'lib/ddtrace/contrib/active_support/notifications/subscription.rb', line 129 def initialize @blocks = {} end |
Instance Attribute Details
#blocks ⇒ Object (readonly)
Returns the value of attribute blocks.
127 128 129 |
# File 'lib/ddtrace/contrib/active_support/notifications/subscription.rb', line 127 def blocks @blocks end |
Instance Method Details
#add(key, &block) ⇒ Object
133 134 135 |
# File 'lib/ddtrace/contrib/active_support/notifications/subscription.rb', line 133 def add(key, &block) blocks_for(key) << block if block_given? end |
#run(event, key, *args) ⇒ Object
137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/ddtrace/contrib/active_support/notifications/subscription.rb', line 137 def run(event, key, *args) blocks_for(key).each do |callback| begin callback.call(event, key, *args) rescue StandardError => e Datadog::Tracer.log.debug( "ActiveSupport::Notifications '#{key}' callback for '#{event}' failed: #{e.}" ) end end end |