Class: ESP::Metadata

Inherits:
Resource show all
Defined in:
lib/esp/resources/metadata.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Dirty

#changed_attributes, #original_attributes, #original_attributes=

Methods included from LoadWithOriginalAttributes

#load

Class Method Details

.find(id) ⇒ ESP::Metadata .find(scope, options) ⇒ ESP::Metadata

Find a Metadata object by id

call-seq -> super.find(id)

Overloads:

  • .find(id) ⇒ ESP::Metadata

    Parameters:

    • id (Integer, Numeric, #to_i)

      Required ID of the metadata object to retrieve.

  • .find(scope, options) ⇒ ESP::Metadata

    This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

    call-seq -> super.find(:one, options)

    Parameters:

    • scope (Object)

      Example: :one

    • options (Hash)

      params: { alert_id: Integer }

    Raises:

    • (ArgumentError)

      if no alert_id is supplied.

Returns:



51
52
53
54
55
56
57
58
# File 'lib/esp/resources/metadata.rb', line 51

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
  alert_id = params.delete(:alert_id)
  for_alert(alert_id)
end

.for_alert(alert_id = nil) ⇒ ESP::Metadata

Returns a metadata object for the given alert_id Convenience method to use instead of find since an alert_id is required to return metadata.

Examples:

alerts = ESP::Metadata.for_alert(1194)

Parameters:

  • alert_id (Integer, Numeric, #to_i) (defaults to: nil)

    Required ID of the alert to retrieve metadata for.

Returns:

Raises:

  • (ArgumentError)

    if no alert_id is supplied.



32
33
34
35
36
# File 'lib/esp/resources/metadata.rb', line 32

def self.for_alert(alert_id = nil)
  fail ArgumentError, "You must supply an alert id." unless alert_id.present?
  from = "#{prefix}alerts/#{alert_id}/metadata.json"
  find(:one, from: from)
end

.wherevoid

This method returns an undefined value.

Not Implemented. You cannot search for Metadata.



6
7
8
# File 'lib/esp/resources/metadata.rb', line 6

def self.where(*)
  fail ESP::NotImplementedError
end

Instance Method Details

#destroyvoid

This method returns an undefined value.

Not Implemented. You cannot destroy Metadata.



20
21
22
# File 'lib/esp/resources/metadata.rb', line 20

def destroy
  fail ESP::NotImplementedError
end

#savevoid

This method returns an undefined value.

Not Implemented. You cannot create or update Metadata.



13
14
15
# File 'lib/esp/resources/metadata.rb', line 13

def save
  fail ESP::NotImplementedError
end