Class: ForestLiana::StatGetter
- Inherits:
-
BaseGetter
- Object
- BaseGetter
- ForestLiana::StatGetter
- Defined in:
- app/services/forest_liana/stat_getter.rb
Direct Known Subclasses
LeaderboardStatGetter, LineStatGetter, PieStatGetter, ValueStatGetter
Instance Attribute Summary collapse
-
#record ⇒ Object
Returns the value of attribute record.
Instance Method Summary collapse
- #get_resource ⇒ Object
-
#initialize(resource, params, forest_user) ⇒ StatGetter
constructor
A new instance of StatGetter.
- #validate_params ⇒ Object
Methods inherited from BaseGetter
#get_collection, #includes_for_serialization
Constructor Details
#initialize(resource, params, forest_user) ⇒ StatGetter
Returns a new instance of StatGetter.
5 6 7 8 9 10 11 12 |
# File 'app/services/forest_liana/stat_getter.rb', line 5 def initialize(resource, params, forest_user) @resource = resource @params = params @user = forest_user validate_params compute_includes end |
Instance Attribute Details
#record ⇒ Object
Returns the value of attribute record.
3 4 5 |
# File 'app/services/forest_liana/stat_getter.rb', line 3 def record @record end |
Instance Method Details
#get_resource ⇒ Object
20 21 22 23 |
# File 'app/services/forest_liana/stat_getter.rb', line 20 def get_resource super @resource.reorder('') end |
#validate_params ⇒ Object
14 15 16 17 18 |
# File 'app/services/forest_liana/stat_getter.rb', line 14 def validate_params if @params.key?(:aggregator) && !%w[count sum avg max min].include?(@params[:aggregator].downcase) raise ForestLiana::Errors::HTTP422Error.new('Invalid aggregate function') end end |