Class: Alula::RestResource

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

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, #initialize, #model_name, #reconstruct_from, #refresh

Constructor Details

This class inherits a constructor from Alula::ApiResource

Class Method Details

.resource_url(id = nil) ⇒ Object

TODO: Not sure if the period replace is applicatble to our use

determine as we add child resources


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

def self.resource_url(id = nil)
  if self == RestResource
    raise NotImplementedError, "Cannot call resource_url on a RestResource. Try using Device or Customer instead."
  end
  "/rest/v1/#{self.get_resource_path(id)}"
end

Instance Method Details

#resource_url(param_id = nil) ⇒ Object



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

def resource_url(param_id = nil)
  our_id = [id, param_id].compact.first
  self.class.resource_url(our_id)
end