mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
convert duration to an attr_reader
This commit is contained in:
parent
cebe5c2fac
commit
cfca55949f
1 changed files with 3 additions and 6 deletions
|
@ -33,7 +33,7 @@ module ActiveSupport
|
||||||
end
|
end
|
||||||
|
|
||||||
class Event
|
class Event
|
||||||
attr_reader :name, :time, :end, :transaction_id, :payload
|
attr_reader :name, :time, :end, :transaction_id, :payload, :duration
|
||||||
|
|
||||||
def initialize(name, start, ending, transaction_id, payload)
|
def initialize(name, start, ending, transaction_id, payload)
|
||||||
@name = name
|
@name = name
|
||||||
|
@ -41,14 +41,11 @@ module ActiveSupport
|
||||||
@time = start
|
@time = start
|
||||||
@transaction_id = transaction_id
|
@transaction_id = transaction_id
|
||||||
@end = ending
|
@end = ending
|
||||||
end
|
@duration = 1000.0 * (@end - @time)
|
||||||
|
|
||||||
def duration
|
|
||||||
@duration ||= 1000.0 * (@end - @time)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def parent_of?(event)
|
def parent_of?(event)
|
||||||
start = (self.time - event.time) * 1000
|
start = (time - event.time) * 1000
|
||||||
start <= 0 && (start + duration >= event.duration)
|
start <= 0 && (start + duration >= event.duration)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue