Class: Pingpp::SingletonAppBasedResource

Inherits:
APIResource show all
Defined in:
lib/pingpp/singleton_app_based_resource.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from APIResource

class_name, object_name, #refresh, uri_object_name

Methods included from APIOperations::Request

included

Methods inherited from PingppObject

#==, #[], #[]=, #_dump, _load, #as_json, construct_from, #each, #initialize, #inspect, #keys, #refresh_from, #respond_to?, #serialize_params, #to_hash, #to_json, #to_s, #values

Constructor Details

This class inherits a constructor from Pingpp::PingppObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Pingpp::PingppObject

Class Method Details

.resource_url(opts = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/pingpp/singleton_app_based_resource.rb', line 3

def self.resource_url(opts={})
  if self == SingletonAPIResource
    raise NotImplementedError.new('SingletonAPIResource is an abstract class.')
  end

  app_id = opts[:app]
  unless app_id ||= Pingpp.app_id
    raise InvalidRequestError.new("Please set app_id using Pingpp.app_id = <APP_ID>", 'app_id')
  end

  "/v1/apps/#{app_id}/#{CGI.escape(uri_object_name.downcase)}"
end

.retrieve(params = {}, opts = {}) ⇒ Object



20
21
22
23
24
# File 'lib/pingpp/singleton_app_based_resource.rb', line 20

def self.retrieve(params={}, opts={})
  instance = self.new(params, Util.normalize_opts(opts))
  instance.refresh
  instance
end

Instance Method Details

#resource_url(opts = {}) ⇒ Object



16
17
18
# File 'lib/pingpp/singleton_app_based_resource.rb', line 16

def resource_url(opts={})
  self.class.resource_url(opts)
end