Class: DomoscioRails::Resource
- Inherits:
-
Object
- Object
- DomoscioRails::Resource
show all
- Defined in:
- lib/domoscio_rails/resource.rb
Direct Known Subclasses
Analytic, Content, Device, Event, Export, ExportRequest, GameplayUtil, Instance, KnowledgeEdge, KnowledgeGraph, KnowledgeGraphNode, KnowledgeGraphScale, KnowledgeNode, KnowledgeNodeContent, KnowledgeNodeStudent, KpiLog, LearningProgram, LearningProgramStudent, LearningSession, LearningSessionKnowledgeNode, LearningSessionRecommendation, Lxp, Objective, ObjectiveKnowledgeNode, ObjectiveKnowledgeNodeStudent, ObjectiveStudent, Question, Recommendation, RecommendationUtil, ReviewUtil, Scale, Scorm, StatsUtil, Student, StudentGroup, Subscription, Tag, TagEdge, TagSet, Tagging
Class Method Summary
collapse
Class Method Details
.class_name ⇒ Object
4
5
6
|
# File 'lib/domoscio_rails/resource.rb', line 4
def class_name
name.split('::')[-1]
end
|
.raw_params(params = {}) ⇒ Object
29
30
31
32
33
|
# File 'lib/domoscio_rails/resource.rb', line 29
def raw_params(params = {})
params.merge({
instance_id: DomoscioRails.configuration.client_id
})
end
|
.raw_url(util_name) ⇒ Object
19
20
21
22
23
24
25
26
27
|
# File 'lib/domoscio_rails/resource.rb', line 19
def raw_url(util_name)
raise NotImplementedError, 'Resource is an abstract class. Do not use it directly.' if self == Resource
build_url = "/v#{DomoscioRails.configuration.version}"
build_url << "/#{underscore(class_name)}s"
build_url << "/#{util_name}" if util_name
build_url
end
|
.underscore(string) ⇒ Object
35
36
37
38
39
40
41
|
# File 'lib/domoscio_rails/resource.rb', line 35
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, util_name = nil) ⇒ Object
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/domoscio_rails/resource.rb', line 8
def url(id = nil, util_name = nil)
raise NotImplementedError, 'Resource is an abstract class. Do not use it directly.' if self == Resource
build_url = "/v#{DomoscioRails.configuration.version}/instances/#{DomoscioRails.configuration.client_id}"
build_url << "/#{underscore(class_name)}s"
build_url << "/#{util_name}" if util_name
build_url << "/#{CGI.escape(id.to_s)}" if id
build_url
end
|