Class: Lita::Extensions::Confirmation

Inherits:
Object
  • Object
show all
Defined in:
lib/lita/extensions/confirmation.rb,
lib/lita/extensions/confirmation/unconfirmed_command.rb

Defined Under Namespace

Classes: UnconfirmedCommand

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(handler, message, robot, route) ⇒ Confirmation

Returns a new instance of Confirmation.



15
16
17
18
19
20
# File 'lib/lita/extensions/confirmation.rb', line 15

def initialize(handler, message, robot, route)
  @handler = handler
  @message = message
  @robot = robot
  @route = route
end

Instance Attribute Details

#handlerObject (readonly)

Returns the value of attribute handler.



4
5
6
# File 'lib/lita/extensions/confirmation.rb', line 4

def handler
  @handler
end

#messageObject (readonly)

Returns the value of attribute message.



4
5
6
# File 'lib/lita/extensions/confirmation.rb', line 4

def message
  @message
end

#robotObject (readonly)

Returns the value of attribute robot.



4
5
6
# File 'lib/lita/extensions/confirmation.rb', line 4

def robot
  @robot
end

#routeObject (readonly)

Returns the value of attribute route.



4
5
6
# File 'lib/lita/extensions/confirmation.rb', line 4

def route
  @route
end

Class Method Details

.call(payload) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/lita/extensions/confirmation.rb', line 6

def self.call(payload)
  new(
    payload.fetch(:handler),
    payload.fetch(:message),
    payload.fetch(:robot),
    payload.fetch(:route)
  ).call
end

Instance Method Details

#callObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/lita/extensions/confirmation.rb', line 22

def call
  if (options = route.extensions[:confirmation])
    message.reply(
      I18n.t(
        "lita.extensions.confirmation.request",
        code: UnconfirmedCommand.new(handler, message, robot, route, options).code
      )
    )

    return false
  end

  true
end