Class: DomoscioAdmin::ResourceInstance
- Inherits:
-
Resource
- Object
- Resource
- DomoscioAdmin::ResourceInstance
show all
- Defined in:
- lib/domoscio_admin/resources/resource_instance.rb
Class Method Summary
collapse
Methods inherited from Resource
class_name
Class Method Details
.underscore(string) ⇒ Object
12
13
14
15
16
17
18
|
# File 'lib/domoscio_admin/resources/resource_instance.rb', line 12
def underscore(string)
string.gsub(/::/, '/')
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
.tr('-', '_')
.downcase
end
|
.url(id = nil) ⇒ Object
4
5
6
7
8
9
10
|
# File 'lib/domoscio_admin/resources/resource_instance.rb', line 4
def url(id = nil)
raise NotImplementedError, 'Resource is an abstract class. Do not use it directly.' if self == Resource
build_url = "/instances/#{DomoscioAdmin.configuration.client_id}/#{underscore(class_name)}s"
build_url << "/#{CGI.escape(id.to_s).gsub('.', '%2E')}" if id
build_url
end
|