Class: Octobat::SingletonAPIResource

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

Instance Attribute Summary

Attributes inherited from OctobatObject

#api_key, #parent_obj

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from APIResource

class_name, #refresh

Methods inherited from OctobatObject

#[], #[]=, #_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 Octobat::OctobatObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Octobat::OctobatObject

Class Method Details

.retrieve(api_key = nil) ⇒ Object



14
15
16
17
18
# File 'lib/octobat/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/octobat/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
  "/v1/#{CGI.escape(class_name.downcase)}"
end

Instance Method Details

#urlObject



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

def url
  self.class.url
end