Class: SakaiInfo::CalendarEvent
Instance Attribute Summary collapse
#attributes, #properties, #xml, #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
Returns a new instance of CalendarEvent.
165
166
167
168
169
170
171
172
173
|
# File 'lib/sakai-info/calendar.rb', line 165
def initialize(dbrow)
@dbrow = dbrow
@id = dbrow[:event_id]
@calendar_id = dbrow[:calendar_id]
@range_start = dbrow[:range_start]
@range_end = dbrow[:range_end]
parse_xml
end
|
Instance Attribute Details
#calendar_id ⇒ Object
Returns the value of attribute calendar_id.
158
159
160
|
# File 'lib/sakai-info/calendar.rb', line 158
def calendar_id
@calendar_id
end
|
#dbrow ⇒ Object
Returns the value of attribute dbrow.
158
159
160
|
# File 'lib/sakai-info/calendar.rb', line 158
def dbrow
@dbrow
end
|
#event_end ⇒ Object
Returns the value of attribute event_end.
158
159
160
|
# File 'lib/sakai-info/calendar.rb', line 158
def event_end
@event_end
end
|
#event_start ⇒ Object
Returns the value of attribute event_start.
158
159
160
|
# File 'lib/sakai-info/calendar.rb', line 158
def event_start
@event_start
end
|
#range_end ⇒ Object
Returns the value of attribute range_end.
158
159
160
|
# File 'lib/sakai-info/calendar.rb', line 158
def range_end
@range_end
end
|
#range_start ⇒ Object
Returns the value of attribute range_start.
158
159
160
|
# File 'lib/sakai-info/calendar.rb', line 158
def range_start
@range_start
end
|
Class Method Details
.all_serializations ⇒ Object
253
254
255
256
257
258
259
260
261
|
# File 'lib/sakai-info/calendar.rb', line 253
def self.all_serializations
[
:default,
:attributes,
:properties,
:mod,
:xml,
]
end
|
.clear_cache ⇒ Object
160
161
162
|
# File 'lib/sakai-info/calendar.rb', line 160
def self.clear_cache
@@cache = {}
end
|
.count_by_calendar_id(calendar_id) ⇒ Object
199
200
201
|
# File 'lib/sakai-info/calendar.rb', line 199
def self.count_by_calendar_id(calendar_id)
CalendarEvent.query_by_calendar_id(calendar_id).count
end
|
.find(id) ⇒ Object
175
176
177
178
179
180
181
182
183
184
185
|
# File 'lib/sakai-info/calendar.rb', line 175
def self.find(id)
if @@cache[id].nil?
xml = ""
row = DB.connect[:calendar_event].where(:event_id => id).first
if row.nil?
raise ObjectNotFoundException.new(CalendarEvent, id)
end
@@cache[id] = CalendarEvent.new(row)
end
@@cache[id]
end
|
.find_by_calendar_id(calendar_id) ⇒ Object
203
204
205
206
207
|
# File 'lib/sakai-info/calendar.rb', line 203
def self.find_by_calendar_id(calendar_id)
CalendarEvent.query_by_calendar_id(calendar_id).all.collect do |row|
@@cache[row[:event_id]] = CalendarEvent.new(row)
end
end
|
.query_by_calendar_id(calendar_id) ⇒ Object
195
196
197
|
# File 'lib/sakai-info/calendar.rb', line 195
def self.query_by_calendar_id(calendar_id)
DB.connect[:calendar_event].where(:calendar_id => calendar_id)
end
|
Instance Method Details
#calendar ⇒ Object
209
210
211
|
# File 'lib/sakai-info/calendar.rb', line 209
def calendar
@calendar ||= Calendar.find(self.calendar_id)
end
|
#default_serialization ⇒ Object
226
227
228
229
230
231
232
233
234
235
236
|
# File 'lib/sakai-info/calendar.rb', line 226
def default_serialization
{
"id" => self.id,
"calendar_id" => self.calendar_id,
"display_name" => self.display_name,
"description" => self.description,
"type" => self.type,
"event_start" => self.event_start,
"event_end" => self.event_end,
}
end
|
#description ⇒ Object
217
218
219
|
# File 'lib/sakai-info/calendar.rb', line 217
def description
@description ||= self.properties["CHEF:description"]
end
|
#display_name ⇒ Object
213
214
215
|
# File 'lib/sakai-info/calendar.rb', line 213
def display_name
@display_name ||= self.properties["DAV:displayname"]
end
|
#summary_serialization ⇒ Object
238
239
240
241
242
243
244
245
|
# File 'lib/sakai-info/calendar.rb', line 238
def summary_serialization
{
"id" => self.id,
"display_name" => self.display_name,
"type" => self.type,
"event_start_date" => self.event_start.strftime("%Y-%m-%d"),
}
end
|
#type ⇒ Object
221
222
223
|
# File 'lib/sakai-info/calendar.rb', line 221
def type
@type ||= self.properties["CHEF:calendar-type"]
end
|
#xml_serialization ⇒ Object
247
248
249
250
251
|
# File 'lib/sakai-info/calendar.rb', line 247
def xml_serialization
{
"xml" => self.xml
}
end
|