class Operation
Attributes
children[R]
parent[R]
Public Class Methods
new(object:, method:, parent: nil, started_at: Time.now, completed_at: nil, children: [])
click to toggle source
# File lib/yuslow/operation.rb, line 10 def initialize(object:, method:, parent: nil, started_at: Time.now, completed_at: nil, children: []) @object = object @method = method @started_at = started_at @completed_at = completed_at @parent = parent @children = children end
start(object, method)
click to toggle source
# File lib/yuslow/operation.rb, line 5 def start(object, method) new(object, method) end
Public Instance Methods
complete()
click to toggle source
# File lib/yuslow/operation.rb, line 30 def complete raise 'This operation is already completed' if @completed_at @completed_at = Time.now end
elapsed()
click to toggle source
# File lib/yuslow/operation.rb, line 36 def elapsed ((@completed_at - @started_at) * 1000).round if @completed_at end
fork(object:, method:)
click to toggle source
# File lib/yuslow/operation.rb, line 19 def fork(object:, method:) operation = self.class.new object: object, method: method, parent: self @children << operation operation end
identifier()
click to toggle source
# File lib/yuslow/operation.rb, line 26 def identifier "#{@object}##{@method}" end