Class: Tally::RecordSearcher
- Inherits:
-
Object
- Object
- Tally::RecordSearcher
- Defined in:
- lib/tally/record_searcher.rb
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Class Method Summary collapse
Instance Method Summary collapse
- #days ⇒ Object
-
#initialize(params = {}) ⇒ RecordSearcher
constructor
A new instance of RecordSearcher.
- #keys ⇒ Object
- #records ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ RecordSearcher
Returns a new instance of RecordSearcher.
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/tally/record_searcher.rb', line 6 def initialize(params = {}) @params = params || {} if ActionController::Parameters === params if params.permitted? @params = params.to_h else @params = {} end end @params = @params.symbolize_keys end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
4 5 6 |
# File 'lib/tally/record_searcher.rb', line 4 def params @params end |
Class Method Details
.search(params = {}) ⇒ Object
32 33 34 |
# File 'lib/tally/record_searcher.rb', line 32 def self.search(params = {}) new(params).records end |
Instance Method Details
#days ⇒ Object
20 21 22 |
# File 'lib/tally/record_searcher.rb', line 20 def days @keys ||= build_search_scope.select(:day).distinct.reorder(day: :desc) end |
#keys ⇒ Object
24 25 26 |
# File 'lib/tally/record_searcher.rb', line 24 def keys @keys ||= build_search_scope.select(:key).distinct.reorder(:key) end |
#records ⇒ Object
28 29 30 |
# File 'lib/tally/record_searcher.rb', line 28 def records @records ||= build_search_scope end |