Class: Groups::UpdateStatisticsService
- Inherits:
-
Object
- Object
- Groups::UpdateStatisticsService
- Defined in:
- app/services/groups/update_statistics_service.rb
Instance Attribute Summary collapse
-
#group ⇒ Object
readonly
Returns the value of attribute group.
-
#statistics ⇒ Object
readonly
Returns the value of attribute statistics.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(group, statistics: []) ⇒ UpdateStatisticsService
constructor
A new instance of UpdateStatisticsService.
Constructor Details
#initialize(group, statistics: []) ⇒ UpdateStatisticsService
Returns a new instance of UpdateStatisticsService.
7 8 9 10 |
# File 'app/services/groups/update_statistics_service.rb', line 7 def initialize(group, statistics: []) @group = group @statistics = statistics end |
Instance Attribute Details
#group ⇒ Object (readonly)
Returns the value of attribute group.
5 6 7 |
# File 'app/services/groups/update_statistics_service.rb', line 5 def group @group end |
#statistics ⇒ Object (readonly)
Returns the value of attribute statistics.
5 6 7 |
# File 'app/services/groups/update_statistics_service.rb', line 5 def statistics @statistics end |
Instance Method Details
#execute ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'app/services/groups/update_statistics_service.rb', line 12 def execute unless group return ServiceResponse.error(message: 'Invalid group', http_status: 400) end namespace_statistics.refresh!(only: statistics.map(&:to_sym)) ServiceResponse.success(message: 'Group statistics successfully updated.') end |