Class: Shrine::Plugins::Instrumentation::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/shrine/plugins/instrumentation.rb

Overview

Abstracts away different kind of event objects (`ActiveSupport::Notifications::Event` and `Dry::Events::Event`).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(event) ⇒ Event

Returns a new instance of Event.


185
186
187
# File 'lib/shrine/plugins/instrumentation.rb', line 185

def initialize(event)
  @event = event
end

Instance Attribute Details

#eventObject (readonly)

Returns the value of attribute event.


183
184
185
# File 'lib/shrine/plugins/instrumentation.rb', line 183

def event
  @event
end

Instance Method Details

#[](name) ⇒ Object


197
198
199
# File 'lib/shrine/plugins/instrumentation.rb', line 197

def [](name)
  event.payload.fetch(name)
end

#durationObject


201
202
203
# File 'lib/shrine/plugins/instrumentation.rb', line 201

def duration
  library_send(:duration)
end

#nameObject


189
190
191
# File 'lib/shrine/plugins/instrumentation.rb', line 189

def name
  library_send(:name).chomp(".shrine").to_sym
end

#payloadObject


193
194
195
# File 'lib/shrine/plugins/instrumentation.rb', line 193

def payload
  event.payload
end