Class: RailsBand::BaseEvent

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_band/base_event.rb

Overview

The base class of each Event class.

Direct Known Subclasses

ActionCable::Event::Broadcast, ActionCable::Event::PerformAction, ActionCable::Event::Transmit, ActionCable::Event::TransmitSubscriptionConfirmation, ActionCable::Event::TransmitSubscriptionRejection, ActionController::Event::ExistFragment, ActionController::Event::ExpireFragment, ActionController::Event::HaltedCallback, ActionController::Event::ProcessAction, ActionController::Event::RateLimit, ActionController::Event::ReadFragment, ActionController::Event::RedirectTo, ActionController::Event::SendData, ActionController::Event::SendFile, ActionController::Event::SendStream, ActionController::Event::StartProcessing, ActionController::Event::UnpermittedParameters, ActionController::Event::WriteFragment, ActionDispatch::Event::ProcessMiddleware, ActionDispatch::Event::Redirect, ActionDispatch::Event::Request, ActionMailbox::Event::Process, ActionMailer::Event::Deliver, ActionMailer::Event::Process, ActionView::Event::RenderCollection, ActionView::Event::RenderLayout, ActionView::Event::RenderPartial, ActionView::Event::RenderTemplate, ActiveJob::Event::Discard, ActiveJob::Event::Enqueue, ActiveJob::Event::EnqueueAll, ActiveJob::Event::EnqueueAt, ActiveJob::Event::EnqueueRetry, ActiveJob::Event::Interrupt, ActiveJob::Event::Perform, ActiveJob::Event::PerformStart, ActiveJob::Event::Resume, ActiveJob::Event::RetryStopped, ActiveJob::Event::Step, ActiveJob::Event::StepSkipped, ActiveJob::Event::StepStarted, ActiveRecord::Event::DeprecatedAssociation, ActiveRecord::Event::Instantiation, ActiveRecord::Event::Sql, ActiveRecord::Event::StartTransaction, ActiveRecord::Event::StrictLoadingViolation, ActiveRecord::Event::Transaction, ActiveStorage::Event::Analyze, ActiveStorage::Event::Preview, ActiveStorage::Event::ServiceDelete, ActiveStorage::Event::ServiceDeletePrefixed, ActiveStorage::Event::ServiceDownload, ActiveStorage::Event::ServiceDownloadChunk, ActiveStorage::Event::ServiceExist, ActiveStorage::Event::ServiceStreamingDownload, ActiveStorage::Event::ServiceUpdateMetadata, ActiveStorage::Event::ServiceUpload, ActiveStorage::Event::ServiceUrl, ActiveStorage::Event::Transform, ActiveSupport::Event::CacheCleanup, ActiveSupport::Event::CacheDecrement, ActiveSupport::Event::CacheDelete, ActiveSupport::Event::CacheDeleteMatched, ActiveSupport::Event::CacheDeleteMulti, ActiveSupport::Event::CacheExist, ActiveSupport::Event::CacheFetchHit, ActiveSupport::Event::CacheGenerate, ActiveSupport::Event::CacheIncrement, ActiveSupport::Event::CachePrune, ActiveSupport::Event::CacheRead, ActiveSupport::Event::CacheReadMulti, ActiveSupport::Event::CacheWrite, ActiveSupport::Event::CacheWriteMulti, ActiveSupport::Event::MessageSerializerFallback, DeprecationSubscriber::DeprecationEvent, Railties::Event::LoadConfigInitializer

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(event) ⇒ BaseEvent

Returns a new instance of BaseEvent.

Parameters:

  • event (ActiveSupport::Notifications::Event)


10
11
12
13
14
15
16
17
18
19
20
# File 'lib/rails_band/base_event.rb', line 10

def initialize(event)
  @event = event
  @name = event.name
  @time = event.time
  @end = event.end
  @transaction_id = event.transaction_id
  @cpu_time = event.cpu_time
  @idle_time = event.idle_time
  @allocations = event.allocations
  @duration = event.duration
end

Instance Attribute Details

#allocations ⇒ Object (readonly)

Returns the value of attribute allocations.



6
7
8
# File 'lib/rails_band/base_event.rb', line 6

def allocations
  @allocations
end

#cpu_time ⇒ Object (readonly)

Returns the value of attribute cpu_time.



6
7
8
# File 'lib/rails_band/base_event.rb', line 6

def cpu_time
  @cpu_time
end

#duration ⇒ Object (readonly)

Returns the value of attribute duration.



6
7
8
# File 'lib/rails_band/base_event.rb', line 6

def duration
  @duration
end

#end ⇒ Object (readonly)

Returns the value of attribute end.



6
7
8
# File 'lib/rails_band/base_event.rb', line 6

def end
  @end
end

#idle_time ⇒ Object (readonly)

Returns the value of attribute idle_time.



6
7
8
# File 'lib/rails_band/base_event.rb', line 6

def idle_time
  @idle_time
end

#name ⇒ Object (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/rails_band/base_event.rb', line 6

def name
  @name
end

#time ⇒ Object (readonly)

Returns the value of attribute time.



6
7
8
# File 'lib/rails_band/base_event.rb', line 6

def time
  @time
end

#transaction_id ⇒ Object (readonly)

Returns the value of attribute transaction_id.



6
7
8
# File 'lib/rails_band/base_event.rb', line 6

def transaction_id
  @transaction_id
end

Instance Method Details

#slice(*args) ⇒ Object



33
34
35
# File 'lib/rails_band/base_event.rb', line 33

def slice(*args)
  to_h.slice(*args)
end

#to_h ⇒ Object



22
23
24
25
26
27
28
29
30
31
# File 'lib/rails_band/base_event.rb', line 22

def to_h
  @to_h ||= {
    name: @name, time: @time, end: @end, transaction_id: @transaction_id,
    cpu_time: @cpu_time, idle_time: @idle_time, allocations: @allocations, duration: @duration
  }.merge!(
    public_methods(false).reject { |meth| non_hash_keys.include?(meth) }.to_h do |meth|
      [meth, public_send(meth)]
    end
  )
end