Class: ActiveSupport::Notifications::Fanout::Handle
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Instance Chain:
|
|
Inherits: | Object |
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 use 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
Class Method Summary
- .new(notifier, name, id, payload) ⇒ Handle constructor Internal use only
Instance Method Summary
- #finish
- #start
- #ensure_state!(expected) private
- #finish_with_values(name, id, payload) Internal use only
::ActiveSupport::Notifications::FanoutIteration
- Included
Constructor Details
.new(notifier, name, id, payload) ⇒ Handle
This method is for internal use only.
# File 'activesupport/lib/active_support/notifications/fanout.rb', line 230
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
#ensure_state!(expected) (private)
[ GitHub ]#finish
[ GitHub ]# File 'activesupport/lib/active_support/notifications/fanout.rb', line 249
def finish finish_with_values(@name, @id, @payload) end
#finish_with_values(name, id, payload)
This method is for internal use only.
[ GitHub ]
# File 'activesupport/lib/active_support/notifications/fanout.rb', line 253
def finish_with_values(name, id, payload) # :nodoc: ensure_state! :started @state = :finished iterate_guarding_exceptions(@groups) do |group| group.finish(name, id, payload) end end
#start
[ GitHub ]# File 'activesupport/lib/active_support/notifications/fanout.rb', line 240
def start ensure_state! :initialized @state = :started iterate_guarding_exceptions(@groups) do |group| group.start(@name, @id, @payload) end end