Module: Hector::Concerns::Presence
- Included in:
- Session
- Defined in:
- lib/hector/concerns/presence.rb
Class Method Summary collapse
Instance Method Summary collapse
- #channels ⇒ Object
- #destroy_presence ⇒ Object
- #initialize_presence ⇒ Object
- #peer_sessions ⇒ Object
- #seconds_idle ⇒ Object
- #touch_presence ⇒ Object
Class Method Details
.included(klass) ⇒ Object
4 5 6 7 8 |
# File 'lib/hector/concerns/presence.rb', line 4 def self.included(klass) klass.class_eval do attr_reader :created_at, :updated_at end end |
Instance Method Details
#channels ⇒ Object
10 11 12 |
# File 'lib/hector/concerns/presence.rb', line 10 def channels Channel.find_all_for_session(self) end |
#destroy_presence ⇒ Object
20 21 22 23 |
# File 'lib/hector/concerns/presence.rb', line 20 def destroy_presence leave_all_channels end |
#initialize_presence ⇒ Object
14 15 16 17 18 |
# File 'lib/hector/concerns/presence.rb', line 14 def initialize_presence @created_at = Time.now @updated_at = Time.now end |
#peer_sessions ⇒ Object
29 30 31 |
# File 'lib/hector/concerns/presence.rb', line 29 def peer_sessions [self, *channels.map { |channel| channel.sessions }.flatten].uniq end |
#seconds_idle ⇒ Object
25 26 27 |
# File 'lib/hector/concerns/presence.rb', line 25 def seconds_idle Time.now - updated_at end |
#touch_presence ⇒ Object
33 34 35 |
# File 'lib/hector/concerns/presence.rb', line 33 def touch_presence @updated_at = Time.now end |