Method: ESP::StatService.for_stat

Defined in:
lib/esp/resources/stat_service.rb

.for_stat(stat_id = nil, options = {}) ⇒ ActiveResource::PaginatedCollection<ESP::StatService>

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.

Examples:

stats = ESP::StatService.for_stat(1194)

Parameters:

  • stat_id (Integer, Numeric) (defaults to: nil)

    Required ID of the stat to list service stats for.

  • options (Hash) (defaults to: {})

    Optional 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

Returns:

Raises:

  • (ArgumentError)

    if no stat_id is supplied.



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