Class: Rave::Models::Event
- Inherits:
-
Object
- Object
- Rave::Models::Event
- Defined in:
- lib/models/event.rb
Overview
Represents an event received from the server.
Direct Known Subclasses
BlipContributorsChanged, BlipDeleted, BlipSubmitted, DocumentChanged, FormButtonClicked, OperationError, WaveletBlipCreated, WaveletBlipRemoved, WaveletCreated, WaveletParticipantsChanged, WaveletSelfAdded, WaveletSelfRemoved, WaveletTimestampChanged, WaveletTitleChanged, WaveletVersionChanged
Defined Under Namespace
Classes: BlipContributorsChanged, BlipDeleted, BlipSubmitted, DocumentChanged, FormButtonClicked, OperationError, WaveletBlipCreated, WaveletBlipRemoved, WaveletCreated, WaveletParticipantsChanged, WaveletSelfAdded, WaveletSelfRemoved, WaveletTimestampChanged, WaveletTitleChanged, WaveletVersionChanged
Constant Summary collapse
- BLIP_ID =
:nodoc:
'blipId'
Constants included from Rave::Mixins::ObjectFactory
Rave::Mixins::ObjectFactory::WILDCARD
Instance Attribute Summary
Attributes included from Rave::Mixins::ObjectFactory
Instance Method Summary collapse
-
#blip ⇒ Object
Blip that caused the event, or wavelet’s root blip for wavelet events [Blip].
-
#blip_id ⇒ Object
ID of the blip that caused the event, or root blip of the wavelet that caused the event [String].
-
#initialize(options = {}) ⇒ Event
constructor
Options include: - :timestamp - :modified_by - :properties - :context Do not use Event.new from outside; instead use Event.create.
-
#modified_by ⇒ Object
The user that caused this event to be generated [User].
-
#timestamp ⇒ Object
Time at which the event was created [Time].
-
#wavelet ⇒ Object
Wavelet that caused the event, or wavelet containing the blip that caused the event [Wavelet].
Methods included from Rave::Mixins::ObjectFactory
Methods included from Rave::Mixins::TimeUtils
Constructor Details
#initialize(options = {}) ⇒ Event
Options include:
-
:timestamp
-
:modified_by
-
:properties
-
:context
Do not use Event.new from outside; instead use Event.create
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/models/event.rb', line 41 def initialize( = {}) # :nodoc: @timestamp = time_from_json([:timestamp]) || Time.now @modified_by_id = [:modified_by] || User::NOBODY_ID @properties = [:properties] || {} @context = [:context] raise ArgumentError.new(":context option required") if @context.nil? add_user_ids([@modified_by_id]) end |
Instance Method Details
#blip ⇒ Object
Blip that caused the event, or wavelet’s root blip for wavelet events [Blip]
31 32 33 |
# File 'lib/models/event.rb', line 31 def blip # :nodoc: @context.blips[@properties[BLIP_ID]] end |
#blip_id ⇒ Object
ID of the blip that caused the event, or root blip of the wavelet that caused the event [String]
16 17 18 |
# File 'lib/models/event.rb', line 16 def blip_id # :nodoc: @properties[BLIP_ID].dup end |
#modified_by ⇒ Object
The user that caused this event to be generated [User]
26 27 28 |
# File 'lib/models/event.rb', line 26 def modified_by # :nodoc: @context.users[@modified_by_id] end |
#timestamp ⇒ Object
Time at which the event was created [Time]
11 12 13 |
# File 'lib/models/event.rb', line 11 def # :nodoc: @timestamp.dup end |
#wavelet ⇒ Object
Wavelet that caused the event, or wavelet containing the blip that caused the event [Wavelet]
21 22 23 |
# File 'lib/models/event.rb', line 21 def wavelet # :nodoc: @context.primary_wavelet end |