Class: Smalltalk::Conversation
- Inherits:
-
Object
- Object
- Smalltalk::Conversation
- Defined in:
- lib/smalltalk/conversation.rb
Instance Attribute Summary collapse
-
#messages ⇒ Object
Returns the value of attribute messages.
-
#owner ⇒ Object
Returns the value of attribute owner.
-
#recipient ⇒ Object
Returns the value of attribute recipient.
-
#sender ⇒ Object
Returns the value of attribute sender.
-
#viewed ⇒ Object
Returns the value of attribute viewed.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(messages) ⇒ Conversation
constructor
A new instance of Conversation.
Constructor Details
#initialize(messages) ⇒ Conversation
Returns a new instance of Conversation.
7 8 9 10 11 12 |
# File 'lib/smalltalk/conversation.rb', line 7 def initialize() self. = self.sender = .first.sender self.recipient = .first.recipient self.viewed = .all?{|m| m.viewed?} end |
Instance Attribute Details
#messages ⇒ Object
Returns the value of attribute messages.
5 6 7 |
# File 'lib/smalltalk/conversation.rb', line 5 def @messages end |
#owner ⇒ Object
Returns the value of attribute owner.
5 6 7 |
# File 'lib/smalltalk/conversation.rb', line 5 def owner @owner end |
#recipient ⇒ Object
Returns the value of attribute recipient.
5 6 7 |
# File 'lib/smalltalk/conversation.rb', line 5 def recipient @recipient end |
#sender ⇒ Object
Returns the value of attribute sender.
5 6 7 |
# File 'lib/smalltalk/conversation.rb', line 5 def sender @sender end |
#viewed ⇒ Object
Returns the value of attribute viewed.
5 6 7 |
# File 'lib/smalltalk/conversation.rb', line 5 def viewed @viewed end |
Class Method Details
.for(messenger) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/smalltalk/conversation.rb', line 14 def self.for(messenger) time_range = (Date.today - 45.days).beginning_of_day..Date.today.end_of_day hash = Smalltalk::Message.visible.for(messenger).created_between(time_range).order("created_at DESC").group_by do |m| if messenger == m.sender "#{m.recipient_type}#{m.recipient_id}" else "#{m.sender_type}#{m.sender_id}" end end hash.map do |k, v| c = Conversation.new(v) c.owner = messenger c end end |