Class: Chatbox::Draft

Inherits:
Object
  • Object
show all
Includes:
FakeMissingKeywords
Defined in:
lib/chatbox/draft.rb

Instance Method Summary collapse

Methods included from FakeMissingKeywords

#req

Constructor Details

#initialize(from: req(:from), to: req(:to), body: req(:body), store: req(:store), id_generator: -> { SecureRandom.uuid }) ⇒ Draft

Returns a new instance of Draft.



8
9
10
11
12
13
14
# File 'lib/chatbox/draft.rb', line 8

def initialize(from: req(:from), to: req(:to), body: req(:body), store: req(:store), id_generator: -> { SecureRandom.uuid })
  @from = from
  @to = to
  @body = body
  @store = store
  @id_generator = id_generator
end

Instance Method Details

#deliver!Object



16
17
18
19
20
21
22
23
# File 'lib/chatbox/draft.rb', line 16

def deliver!
  store.add_message(
    'id' => id_generator.(),
    'from_id' => from.chatbox_id,
    'to_id' => to.chatbox_id,
    'body' => body,
  )
end