Class: ESP::ScanInterval
- Inherits:
-
Resource
- Object
- ActiveResource::Base
- Resource
- ESP::ScanInterval
- Defined in:
- lib/esp/resources/scan_interval.rb
Class Method Summary collapse
-
.find(*arguments) ⇒ ESP::ScanInterval
Find a Scan Interval by id.
-
.for_external_account(external_account_id = nil) ⇒ ActiveResource::PaginatedCollection<ESP::ScanInterval>
Returns a collection of scan_intervals for the given external_account_id Convenience method to use instead of ScanInterval.find since an external_account_id is required to return alerts.
Instance Method Summary collapse
-
#external_account ⇒ ESP::ExternalAccount
The external account the scan interval belongs to.
-
#service ⇒ ESP::Service
The service the scan interval belongs to.
Methods included from Dirty
#changed_attributes, #original_attributes, #original_attributes=
Methods included from LoadWithOriginalAttributes
Class Method Details
.find(id) ⇒ ESP::ScanInterval .find(scope, options) ⇒ ESP::ScanInterval
Find a Scan Interval by id
call-seq -> super.find(id)
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/esp/resources/scan_interval.rb', line 26 def self.find(*arguments) scope = arguments.slice!(0) = (arguments.slice!(0) || {}).with_indifferent_access # If the first option is a number, we are looking for a specific object. # Otherwise `all` calls this with either nil, or a hash of arguments, and we need # to use our custom finder to use the correct URL return super(scope, ) if scope.is_a?(Numeric) || [:from].present? params = .fetch(:params, {}).with_indifferent_access external_account_id = params.delete(:external_account_id) for_external_account(external_account_id) end |
.for_external_account(external_account_id = nil) ⇒ ActiveResource::PaginatedCollection<ESP::ScanInterval>
Returns a collection of scan_intervals for the given external_account_id Convenience method to use instead of find since an external_account_id is required to return alerts.
46 47 48 49 50 |
# File 'lib/esp/resources/scan_interval.rb', line 46 def self.for_external_account(external_account_id = nil) fail ArgumentError, "You must supply an external account id." unless external_account_id.present? from = "#{prefix}external_accounts/#{external_account_id}/scan_intervals.json" all(from: from) end |
Instance Method Details
#external_account ⇒ ESP::ExternalAccount
The external account the scan interval belongs to
6 |
# File 'lib/esp/resources/scan_interval.rb', line 6 belongs_to :external_account, class_name: 'ESP::ExternalAccount' |
#service ⇒ ESP::Service
The service the scan interval belongs to
11 |
# File 'lib/esp/resources/scan_interval.rb', line 11 belongs_to :service, class_name: 'ESP::Service' |