Class: SakaiInfo::SakaiObject
- Inherits:
-
Object
- Object
- SakaiInfo::SakaiObject
show all
- Defined in:
- lib/sakai-info/sakai_object.rb
Overview
this class forms the basis of all other Sakai object abstractions
Direct Known Subclasses
AuthzFunction, AuthzRealm, AuthzRealmMembership, AuthzRealmRole, AuthzRole, Content, Forum, GenericMessage, GradableObject, Gradebook, Group, Page, QuestionPool, Quiz, QuizAttempt, QuizAttemptItem, QuizAttemptItemAttachment, QuizItem, QuizSection, SakaiXMLEntity, Site, SiteMembership, Tool, User
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
most objects will have unique IDs (perhaps the rest should generate their own?).
Class Method Summary
collapse
-
.all_serializations ⇒ Object
support for CLI – returns an array of symbols that can be passed back to #serialize, #to_yaml, or #to_json should be reimplemented in all object classes.
Instance Method Summary
collapse
Instance Attribute Details
#id ⇒ Object
most objects will have unique IDs (perhaps the rest should generate their own?)
17
18
19
|
# File 'lib/sakai-info/sakai_object.rb', line 17
def id
@id
end
|
Class Method Details
.all_serializations ⇒ Object
support for CLI – returns an array of symbols that can be passed back to #serialize, #to_yaml, or #to_json should be reimplemented in all object classes
76
77
78
|
# File 'lib/sakai-info/sakai_object.rb', line 76
def self.all_serializations
[:default]
end
|
Instance Method Details
#dbrow_only_serialization ⇒ Object
53
54
55
56
57
58
59
|
# File 'lib/sakai-info/sakai_object.rb', line 53
def dbrow_only_serialization
if not self.dbrow_serialization["dbrow"].nil?
self.dbrow_serialization["dbrow"]
else
{}
end
end
|
#dbrow_serialization ⇒ Object
43
44
45
46
47
48
49
50
51
|
# File 'lib/sakai-info/sakai_object.rb', line 43
def dbrow_serialization
if self.respond_to? :dbrow
{
"dbrow" => self.dbrow
}
else
{}
end
end
|
#default_serialization ⇒ Object
61
62
63
|
# File 'lib/sakai-info/sakai_object.rb', line 61
def default_serialization
object_type_serialization
end
|
#object_type_serialization ⇒ Object
37
38
39
40
41
|
# File 'lib/sakai-info/sakai_object.rb', line 37
def object_type_serialization
{
"sakai_object_type" => self.class
}
end
|
#serialize(*q) ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/sakai-info/sakai_object.rb', line 19
def serialize(*q)
q.flatten!
if q.length == 0
q = [:default]
end
serialization = {}
q.each do |sub|
sub_method_name = (sub.to_s + "_serialization").to_sym
if self.respond_to? sub_method_name
serialization = serialization.merge(self.method(sub_method_name).call)
end
end
serialization
end
|
#to_json(*q) ⇒ Object
69
70
71
|
# File 'lib/sakai-info/sakai_object.rb', line 69
def to_json(*q)
serialize(q).to_json
end
|
#to_yaml(*q) ⇒ Object
65
66
67
|
# File 'lib/sakai-info/sakai_object.rb', line 65
def to_yaml(*q)
serialize(q).to_yaml
end
|