Class: RecordsCount::Warning
- Inherits:
-
Object
- Object
- RecordsCount::Warning
- Defined in:
- lib/records_count.rb
Constant Summary collapse
- WARNING_TIME =
ms
10
Instance Attribute Summary collapse
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
Instance Method Summary collapse
- #format ⇒ Object
-
#initialize(start, finish) ⇒ Warning
constructor
A new instance of Warning.
- #print ⇒ Object
Constructor Details
#initialize(start, finish) ⇒ Warning
Returns a new instance of Warning.
42 43 44 |
# File 'lib/records_count.rb', line 42 def initialize(start, finish) @duration = (finish - start).round(1) end |
Instance Attribute Details
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
40 41 42 |
# File 'lib/records_count.rb', line 40 def duration @duration end |
Instance Method Details
#format ⇒ Object
46 47 48 |
# File 'lib/records_count.rb', line 46 def format -> { Colorizer.yellow(yield) } end |
#print ⇒ Object
50 51 52 53 54 |
# File 'lib/records_count.rb', line 50 def print if duration > WARNING_TIME Rails.logger.debug format { " Warning instantiation time: #{duration}ms" }.call end end |