Class: Mercy::Report::Range
- Inherits:
-
ActiveRecord
- Object
- Mercy::Report
- ActiveRecord
- Mercy::Report::Range
- Defined in:
- lib/mercy/report/range.rb
Constant Summary collapse
- ALLOWED_PARAMETERS =
[:period, :maximum, :minimum]
- DEFAULT_OPTION =
{ period: 1.day, scope: :all, }
Instance Attribute Summary
Attributes inherited from Mercy::Report
Instance Method Summary collapse
- #as_json ⇒ Object
- #count ⇒ Object
- #error? ⇒ Boolean
-
#initialize(options) ⇒ Range
constructor
A new instance of Range.
- #scoped ⇒ Object
Methods inherited from Mercy::Report
Constructor Details
#initialize(options) ⇒ Range
Returns a new instance of Range.
14 15 16 |
# File 'lib/mercy/report/range.rb', line 14 def initialize() super(DEFAULT_OPTION.merge()) end |
Instance Method Details
#as_json ⇒ Object
26 27 28 29 30 31 |
# File 'lib/mercy/report/range.rb', line 26 def as_json { status: status, count: count } end |
#count ⇒ Object
33 34 35 |
# File 'lib/mercy/report/range.rb', line 33 def count scoped.count end |
#error? ⇒ Boolean
22 23 24 |
# File 'lib/mercy/report/range.rb', line 22 def error? @error ||= !count_in_range? end |
#scoped ⇒ Object
18 19 20 |
# File 'lib/mercy/report/range.rb', line 18 def scoped @scoped ||= fetch_scoped(last_entries, scope) end |