Class: ESP::StatService

Inherits:
Resource
  • Object
show all
Includes:
StatTotals
Defined in:
lib/esp/resources/stat_service.rb

Constant Summary

Constants inherited from Resource

Resource::PREDICATES

Class Method Summary collapse

Instance Method Summary collapse

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, options = {})


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)
  options = (arguments.slice!(0) || {}).with_indifferent_access
  return super(scope, options) if scope.is_a?(Numeric) || options[:from].present?
  params = options.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, options = {}) # 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: options)
end

.whereObject

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

#serviceObject

The service these stats are for.



7
# File 'lib/esp/resources/stat_service.rb', line 7

belongs_to :service, class_name: 'ESP::Service'