Spec-Zone.ru › Ruby on Rails 5.0

класс ActiveSupport::Notifications::Event

Родитель:
Object

Атрибуты

children[R]
end[RW]
name[R]
payload[R]
time[R]
transaction_id[R]

Публичные методы класса

new(name, start, ending, transaction_id, payload) Показать исходный код
# File activesupport/lib/active_support/notifications/instrumenter.rb, line 56
def initialize(name, start, ending, transaction_id, payload)
  @name           = name
  @payload        = payload.dup
  @time           = start
  @transaction_id = transaction_id
  @end            = ending
  @children       = []
  @duration       = nil
end

Публичные методы экземпляра

<<(event) Показать исходный код
# File activesupport/lib/active_support/notifications/instrumenter.rb, line 82
def <<(event)
  @children << event
end
duration() Показать исходный код
# File activesupport/lib/active_support/notifications/instrumenter.rb, line 78
def duration
  @duration ||= 1000.0 * (self.end - time)
end

Возвращает разницу в миллисекундах между началом выполнения события и его окончанием.

ActiveSupport::Notifications.subscribe('wait') do |*args|
  @event = ActiveSupport::Notifications::Event.new(*args)
end

ActiveSupport::Notifications.instrument('wait') do
  sleep 1
end

@event.duration # => 1000.138
parent_of?(event) Показать исходный код
# File activesupport/lib/active_support/notifications/instrumenter.rb, line 86
def parent_of?(event)
  @children.include? event
end

© 2004–2018 David Heinemeier Hansson
Licensed under the MIT License.

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API