Class: ForestLiana::ValueStatGetter
- Inherits:
-
Object
- Object
- ForestLiana::ValueStatGetter
- Defined in:
- app/services/forest_liana/value_stat_getter.rb
Instance Attribute Summary collapse
-
#record ⇒ Object
Returns the value of attribute record.
Instance Method Summary collapse
-
#initialize(resource, params) ⇒ ValueStatGetter
constructor
A new instance of ValueStatGetter.
- #perform ⇒ Object
Constructor Details
#initialize(resource, params) ⇒ ValueStatGetter
Returns a new instance of ValueStatGetter.
5 6 7 8 |
# File 'app/services/forest_liana/value_stat_getter.rb', line 5 def initialize(resource, params) @resource = resource @params = params end |
Instance Attribute Details
#record ⇒ Object
Returns the value of attribute record.
3 4 5 |
# File 'app/services/forest_liana/value_stat_getter.rb', line 3 def record @record end |
Instance Method Details
#perform ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/services/forest_liana/value_stat_getter.rb', line 10 def perform return if @params[:aggregate].blank? value = @resource @params[:filters].try(:each) do |filter| operator, filter_value = OperatorValueParser.parse(filter[:value]) value = OperatorValueParser.add_where(value, filter[:field], operator, filter_value) end @record = Model::Stat.new(value: count(value)) end |