Class: ModelObserver::Metric
- Inherits:
-
Object
- Object
- ModelObserver::Metric
- Defined in:
- lib/model_observer/metric.rb
Instance Attribute Summary collapse
-
#ended_at ⇒ Object
Returns the value of attribute ended_at.
-
#model_class ⇒ Object
Returns the value of attribute model_class.
-
#model_id ⇒ Object
Returns the value of attribute model_id.
-
#started_at ⇒ Object
Returns the value of attribute started_at.
Instance Method Summary collapse
- #duration ⇒ Object
-
#initialize(model, started_at, ended_at) ⇒ Metric
constructor
A new instance of Metric.
Constructor Details
#initialize(model, started_at, ended_at) ⇒ Metric
Returns a new instance of Metric.
5 6 7 8 9 10 |
# File 'lib/model_observer/metric.rb', line 5 def initialize(model, started_at, ended_at) @model_class = model.class @model_id = model.__send__(model.class.primary_key) if model.class.primary_key @started_at = started_at @ended_at = ended_at end |
Instance Attribute Details
#ended_at ⇒ Object
Returns the value of attribute ended_at.
3 4 5 |
# File 'lib/model_observer/metric.rb', line 3 def ended_at @ended_at end |
#model_class ⇒ Object
Returns the value of attribute model_class.
3 4 5 |
# File 'lib/model_observer/metric.rb', line 3 def model_class @model_class end |
#model_id ⇒ Object
Returns the value of attribute model_id.
3 4 5 |
# File 'lib/model_observer/metric.rb', line 3 def model_id @model_id end |
#started_at ⇒ Object
Returns the value of attribute started_at.
3 4 5 |
# File 'lib/model_observer/metric.rb', line 3 def started_at @started_at end |
Instance Method Details
#duration ⇒ Object
12 13 14 |
# File 'lib/model_observer/metric.rb', line 12 def duration ((ended_at.to_f - started_at.to_f) * 1000).round(1) end |