Class: SakaiInfo::CalendarEvent
- Inherits:
-
SakaiXMLEntity
- Object
- SakaiObject
- SakaiXMLEntity
- SakaiInfo::CalendarEvent
- Defined in:
- lib/sakai-info/calendar.rb
Instance Attribute Summary collapse
-
#calendar_id ⇒ Object
readonly
Returns the value of attribute calendar_id.
-
#dbrow ⇒ Object
readonly
Returns the value of attribute dbrow.
-
#event_end ⇒ Object
readonly
Returns the value of attribute event_end.
-
#event_start ⇒ Object
readonly
Returns the value of attribute event_start.
-
#range_end ⇒ Object
readonly
Returns the value of attribute range_end.
-
#range_start ⇒ Object
readonly
Returns the value of attribute range_start.
Attributes inherited from SakaiXMLEntity
#attributes, #properties, #xml, #xmldoc
Attributes inherited from SakaiObject
Class Method Summary collapse
- .all_serializations ⇒ Object
- .clear_cache ⇒ Object
- .count_by_calendar_id(calendar_id) ⇒ Object
- .find(id) ⇒ Object
- .find_by_calendar_id(calendar_id) ⇒ Object
- .query_by_calendar_id(calendar_id) ⇒ Object
Instance Method Summary collapse
- #calendar ⇒ Object
-
#default_serialization ⇒ Object
serialization.
- #description ⇒ Object
- #display_name ⇒ Object
-
#initialize(dbrow) ⇒ CalendarEvent
constructor
A new instance of CalendarEvent.
- #summary_serialization ⇒ Object
- #type ⇒ Object
- #xml_serialization ⇒ Object
Methods inherited from SakaiXMLEntity
#attributes_serialization, #dbrow_serialization, #parse_xml, #properties_serialization
Methods included from ModProps
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) ⇒ CalendarEvent
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 (readonly)
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 (readonly)
Returns the value of attribute dbrow.
158 159 160 |
# File 'lib/sakai-info/calendar.rb', line 158 def dbrow @dbrow end |
#event_end ⇒ Object (readonly)
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 (readonly)
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 (readonly)
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 (readonly)
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 |
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
serialization
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 |