Class: ESP::StatService
- Includes:
- StatTotals
- Defined in:
- lib/esp/resources/stat_service.rb
Constant Summary
Constants inherited from Resource
Class Method Summary collapse
-
.find(*arguments) ⇒ Object
Find a StatService by id.
-
.for_stat(stat_id = nil, options = {}) ⇒ 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.
-
.where ⇒ Object
Not Implemented.
Instance Method Summary collapse
-
#service ⇒ Object
The service these stats are for.
Methods included from StatTotals
#destroy, #save, #total, #total_suppressed
Methods inherited from Resource
arrange_options, filters, make_pageable, #serializable_hash
Class Method Details
.find(*arguments) ⇒ Object
Find a StatService by id
Parameter
id
| Required | The ID of the service stat to retrieve
options
| Optional | A hash of options
Valid Options
include
| The list of associated objects to return on the initial request.
valid Includable Associations
See API documentation for valid arguments
:call-seq:
find(id, = {})
57 58 59 60 61 62 63 64 |
# File 'lib/esp/resources/stat_service.rb', line 57 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, options = {}) ⇒ 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
options
| Optional | A hash of options
Valid Options
include
| The list of associated objects to return on the initial request.
valid Includable Associations
See API documentation for valid arguments
Example
stats = ESP::StatService.for_stat(1194)
33 34 35 36 37 |
# File 'lib/esp/resources/stat_service.rb', line 33 def self.for_stat(stat_id = nil, = {}) # rubocop:disable Style/OptionHash fail ArgumentError, "You must supply a stat id." unless stat_id.present? from = "#{prefix}stats/#{stat_id}/services.json" find(:all, from: from, params: ) end |
.where ⇒ Object
Not Implemented. You cannot search for a StatSignature.
10 11 12 |
# File 'lib/esp/resources/stat_service.rb', line 10 def self.where(*) fail ESP::NotImplementedError end |
Instance Method Details
#service ⇒ Object
The service these stats are for.
7 |
# File 'lib/esp/resources/stat_service.rb', line 7 belongs_to :service, class_name: 'ESP::Service' |