Class: Alula::SingletonRestResource

Inherits:
ApiResource show all
Defined in:
lib/alula/singleton_rest_resource.rb

Direct Known Subclasses

Self

Instance Attribute Summary

Attributes inherited from ApiResource

#dirty_attributes, #errors, #id, #link_matchers, #links, #rate_limit, #raw_data, #values

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApiResource

#annotate_errors, #apply_attributes, #as_json, #as_patchable_json, build, #cache_links, class_name, #clone, #construct_from, #dirty?, #errors?, #filter_builder, #model_name, #reconstruct_from, #refresh

Constructor Details

#initialize(attributes = {}) ⇒ SingletonRestResource

Returns a new instance of SingletonRestResource.



22
23
24
# File 'lib/alula/singleton_rest_resource.rb', line 22

def initialize(attributes = {})
  super(nil, attributes)
end

Class Method Details

.resource_urlObject



3
4
5
6
7
8
9
10
# File 'lib/alula/singleton_rest_resource.rb', line 3

def self.resource_url
  if self == SingletonRestResource
    raise NotImplementedError, "SingletonRestResource is an abstract class.  You should perform actions on its subclasses (Self, etc.)"
  end
  # Namespaces are separated in object names with periods (.) and in URLs
  # with forward slashes (/), so replace the former with the latter.
  "/rest/v1/#{self.get_resource_path}"
end

.retrieveObject



16
17
18
19
20
# File 'lib/alula/singleton_rest_resource.rb', line 16

def self.retrieve
  instance = new
  instance.refresh
  instance
end

Instance Method Details

#resource_urlObject



12
13
14
# File 'lib/alula/singleton_rest_resource.rb', line 12

def resource_url
  self.class.resource_url
end