Class: WitBot::MessageThread

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id = SecureRandom.uuid) ⇒ MessageThread

Returns a new instance of MessageThread.



5
6
7
8
# File 'lib/wit_bot/models/message_thread.rb', line 5

def initialize(id=SecureRandom.uuid)
  @id = id
  @messages = {}
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/wit_bot/models/message_thread.rb', line 3

def id
  @id
end

#messagesObject (readonly)

Returns the value of attribute messages.



3
4
5
# File 'lib/wit_bot/models/message_thread.rb', line 3

def messages
  @messages
end

Instance Method Details

#contextObject



22
23
24
# File 'lib/wit_bot/models/message_thread.rb', line 22

def context
  @context ||= Context.new
end

#create_message(text, id = SecureRandom.uuid) ⇒ Object



18
19
20
# File 'lib/wit_bot/models/message_thread.rb', line 18

def create_message(text, id=SecureRandom.uuid)
  WitBot::Message.new self, text, id: id
end

#message(id) ⇒ Object



10
11
12
# File 'lib/wit_bot/models/message_thread.rb', line 10

def message(id)
  messages[id]
end

#messages_listObject



14
15
16
# File 'lib/wit_bot/models/message_thread.rb', line 14

def messages_list
  messages.values
end

#reset_contextObject



26
27
28
# File 'lib/wit_bot/models/message_thread.rb', line 26

def reset_context
  @context = Context.new
end