Class: SakaiInfo::Calendar
Instance Attribute Summary collapse
#attributes, #properties, #xmldoc
Attributes inherited from SakaiObject
#id
Class Method Summary
collapse
Instance Method Summary
collapse
#attributes_serialization, #dbrow_serialization, #parse_xml, #properties_serialization
Methods included from ModProps
included
Methods inherited from SakaiObject
#dbrow_only_serialization, #dbrow_serialization, descendants, #object_type_serialization, #serialize, #shell_serialization, #to_csv, #to_json, #to_yaml
Constructor Details
#initialize(dbrow) ⇒ Calendar
Returns a new instance of Calendar.
21
22
23
24
25
26
27
|
# File 'lib/sakai-info/calendar.rb', line 21
def initialize(dbrow)
@dbrow = dbrow
@id = dbrow[:calendar_id]
@next_id = dbrow[:next_id]
parse_xml
end
|
Instance Attribute Details
#dbrow ⇒ Object
Returns the value of attribute dbrow.
14
15
16
|
# File 'lib/sakai-info/calendar.rb', line 14
def dbrow
@dbrow
end
|
#next_id ⇒ Object
Returns the value of attribute next_id.
14
15
16
|
# File 'lib/sakai-info/calendar.rb', line 14
def next_id
@next_id
end
|
Class Method Details
.all_serializations ⇒ Object
109
110
111
112
113
114
115
116
|
# File 'lib/sakai-info/calendar.rb', line 109
def self.all_serializations
[
:default,
:xml,
:mod,
:events,
]
end
|
.clear_cache ⇒ Object
16
17
18
|
# File 'lib/sakai-info/calendar.rb', line 16
def self.clear_cache
@@cache = {}
end
|
.find(id) ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/sakai-info/calendar.rb', line 29
def self.find(id)
if id !~ /\//
id = "/calendar/calendar/#{id}/main"
end
if @@cache[id].nil?
xml = ""
row = DB.connect[:calendar_calendar].where(:calendar_id => id).first
if row.nil?
raise ObjectNotFoundException.new(Calendar, id)
end
@@cache[id] = Calendar.new(row)
end
@@cache[id]
end
|
Instance Method Details
#default_serialization ⇒ Object
82
83
84
85
86
87
88
89
|
# File 'lib/sakai-info/calendar.rb', line 82
def default_serialization
{
"id" => self.id,
"site" => self.site.serialize(:summary),
"next_id" => self.next_id,
"event_count" => self.event_count,
}
end
|
#events_serialization ⇒ Object
103
104
105
106
107
|
# File 'lib/sakai-info/calendar.rb', line 103
def events_serialization
{
"events" => self.events.collect{|e|e.serialize(:summary)}
}
end
|
#site ⇒ Object
69
70
71
|
# File 'lib/sakai-info/calendar.rb', line 69
def site
@site ||= Site.find(self.site_id)
end
|
#site_id ⇒ Object
65
66
67
|
# File 'lib/sakai-info/calendar.rb', line 65
def site_id
@site_id ||= @id.split("/")[3]
end
|
#summary_serialization ⇒ Object
91
92
93
94
95
|
# File 'lib/sakai-info/calendar.rb', line 91
def summary_serialization
{
"id" => self.id,
}
end
|
#xml ⇒ Object
73
74
75
76
77
78
79
|
# File 'lib/sakai-info/calendar.rb', line 73
def xml
if @xml.nil?
@xml = ""
REXML::Document.new(@dbrow[:xml].read).write(@xml, 2)
end
@xml
end
|
#xml_serialization ⇒ Object
97
98
99
100
101
|
# File 'lib/sakai-info/calendar.rb', line 97
def xml_serialization
{
"xml" => self.xml
}
end
|