Class: Chotto::MessageThread

Inherits:
Object
  • Object
show all
Defined in:
lib/chotto/message_thread.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(thread_id:, db:) ⇒ MessageThread

Returns a new instance of MessageThread.



7
8
9
10
# File 'lib/chotto/message_thread.rb', line 7

def initialize(thread_id:, db:)
  @thread_id = thread_id
  @db = db
end

Instance Attribute Details

#dbObject (readonly)

Returns the value of attribute db.



5
6
7
# File 'lib/chotto/message_thread.rb', line 5

def db
  @db
end

#thread_idObject (readonly)

Returns the value of attribute thread_id.



5
6
7
# File 'lib/chotto/message_thread.rb', line 5

def thread_id
  @thread_id
end

Instance Method Details

#eachObject



12
13
14
15
16
17
18
19
20
# File 'lib/chotto/message_thread.rb', line 12

def each
  db.search_messages("thread:#{thread_id}").each do |msg|
    yield(
        Message.new(
          msg: msg,
          db: db
        ))
  end
end