class Shrine::Plugins::Instrumentation::Event
Abstracts away different kind of event objects (‘ActiveSupport::Notifications::Event` and `Dry::Events::Event`).
Attributes
event[R]
Public Class Methods
new(event)
click to toggle source
# File lib/shrine/plugins/instrumentation.rb, line 189 def initialize(event) @event = event end
Public Instance Methods
[](name)
click to toggle source
# File lib/shrine/plugins/instrumentation.rb, line 201 def [](name) event.payload.fetch(name) end
duration()
click to toggle source
# File lib/shrine/plugins/instrumentation.rb, line 205 def duration library_send(:duration) end
name()
click to toggle source
# File lib/shrine/plugins/instrumentation.rb, line 193 def name library_send(:name).chomp(".shrine").to_sym end
payload()
click to toggle source
# File lib/shrine/plugins/instrumentation.rb, line 197 def payload event.payload end
Private Instance Methods
active_support_duration()
click to toggle source
# File lib/shrine/plugins/instrumentation.rb, line 223 def active_support_duration event.duration.to_i end
active_support_name()
click to toggle source
# File lib/shrine/plugins/instrumentation.rb, line 215 def active_support_name event.name end
dry_events_duration()
click to toggle source
# File lib/shrine/plugins/instrumentation.rb, line 219 def dry_events_duration event[:time] end
dry_events_name()
click to toggle source
# File lib/shrine/plugins/instrumentation.rb, line 211 def dry_events_name event.id end
library_send(method_name, *args, &block)
click to toggle source
# File lib/shrine/plugins/instrumentation.rb, line 227 def library_send(method_name, *args, &block) case event.class.name when "ActiveSupport::Notifications::Event" send(:"active_support_#{method_name}", *args, &block) when "Dry::Events::Event" send(:"dry_events_#{method_name}", *args, &block) else event.send(method_name, *args, &block) end end