Class: ActiveSupport::Notifications::Fanout::Handle
- Defined in:
- activesupport/lib/active_support/notifications/fanout.rb
Overview
A Handle
is used to record the start and finish time of event
Both #start and #finish must each be called exactly once
Where possible, it’s best to the block form, ActiveSupport::Notifications.instrument. Handle
is a low-level API intended for cases where the block form can’t be used.
handle = ActiveSupport::Notifications.instrumenter.build_handle("my.event", {})
begin
handle.start
# work to be instrumented
ensure
handle.finish
end
Instance Method Summary collapse
- #finish ⇒ Object
-
#finish_with_values(name, id, payload) ⇒ Object
:nodoc:.
-
#initialize(notifier, name, id, payload) ⇒ Handle
constructor
:nodoc:.
- #start ⇒ Object
Constructor Details
#initialize(notifier, name, id, payload) ⇒ Handle
:nodoc:
228 229 230 231 232 233 234 235 236 |
# File 'activesupport/lib/active_support/notifications/fanout.rb', line 228 def initialize(notifier, name, id, payload) # :nodoc: @name = name @id = id @payload = payload @groups = notifier.groups_for(name).map do |group_klass, grouped_listeners| group_klass.new(grouped_listeners, name, id, payload) end @state = :initialized end |
Instance Method Details
#finish ⇒ Object
247 248 249 |
# File 'activesupport/lib/active_support/notifications/fanout.rb', line 247 def finish finish_with_values(@name, @id, @payload) end |
#finish_with_values(name, id, payload) ⇒ Object
:nodoc:
251 252 253 254 255 256 257 258 |
# File 'activesupport/lib/active_support/notifications/fanout.rb', line 251 def finish_with_values(name, id, payload) # :nodoc: ensure_state! :started @state = :finished @groups.each do |group| group.finish(name, id, payload) end end |
#start ⇒ Object
238 239 240 241 242 243 244 245 |
# File 'activesupport/lib/active_support/notifications/fanout.rb', line 238 def start ensure_state! :initialized @state = :started @groups.each do |group| group.start(@name, @id, @payload) end end |