Class: ESP::StatService
- Includes:
- StatTotals
- Defined in:
- lib/esp/resources/stat_service.rb
Class Method Summary collapse
-
.find(*arguments) ⇒ Object
Find a StatService by id.
-
.for_stat(stat_id = nil) ⇒ Object
Returns a paginated collection of service stats for the given stat_id Convenience method to use instead of ::find since a stat_id is required to return service stats.
Methods included from StatTotals
#destroy, #save, #total, #total_suppressed
Methods inherited from Resource
arrange_options, filters, make_pageable, #serializable_hash, where
Class Method Details
.find(*arguments) ⇒ Object
Find a StatService by id
Parameter
id | Required | The ID of the service stat to retrieve
:call-seq:
find(id)
31 32 33 34 35 36 37 38 |
# File 'lib/esp/resources/stat_service.rb', line 31 def self.find(*arguments) scope = arguments.slice!(0) = (arguments.slice!(0) || {}).with_indifferent_access return super(scope, ) if scope.is_a?(Numeric) || [:from].present? params = .fetch(:params, {}).with_indifferent_access stat_id = params.delete(:stat_id) for_stat(stat_id) end |
.for_stat(stat_id = nil) ⇒ Object
Returns a paginated collection of service stats for the given stat_id Convenience method to use instead of ::find since a stat_id is required to return service stats.
Parameter
stat_id | Required | The ID of the stat to list service stats for
Example
stats = ESP::StatService.for_stat(1194)
17 18 19 20 21 |
# File 'lib/esp/resources/stat_service.rb', line 17 def self.for_stat(stat_id = nil) fail ArgumentError, "You must supply a stat id." unless stat_id.present? from = "#{prefix}stats/#{stat_id}/services.json" find(:all, from: from) end |