Class: Paid::SingletonAPIResource

Inherits:
APIResource show all
Defined in:
lib/paid/singleton_api_resource.rb

Direct Known Subclasses

Account

Instance Attribute Summary

Attributes inherited from PaidObject

#api_key

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from APIResource

class_name, #refresh

Methods inherited from PaidObject

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

Constructor Details

This class inherits a constructor from Paid::PaidObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Paid::PaidObject

Class Method Details

.retrieve(api_key = nil) ⇒ Object



14
15
16
17
18
# File 'lib/paid/singleton_api_resource.rb', line 14

def self.retrieve(api_key=nil)
  instance = self.new(nil, api_key)
  instance.refresh
  instance
end

.urlObject



3
4
5
6
7
8
# File 'lib/paid/singleton_api_resource.rb', line 3

def self.url
  if self == SingletonAPIResource
    raise NotImplementedError.new('SingletonAPIResource is an abstract class.  You should perform actions on its subclasses (Account, etc.)')
  end
  "/v0/#{CGI.escape(class_name.downcase)}"
end

Instance Method Details

#urlObject



10
11
12
# File 'lib/paid/singleton_api_resource.rb', line 10

def url
  self.class.url
end