Class: Lita::Interactors::AddQuantity

Inherits:
BaseInteractor show all
Includes:
Helpers::MessagesHelper
Defined in:
lib/lita/interactors/add_quantity.rb

Overview

Adds the given quantity to the customer’s balance

Constant Summary collapse

DEFAULT_QUANTITY =
1

Instance Attribute Summary collapse

Attributes inherited from BaseInteractor

#error, #handler, #message

Instance Method Summary collapse

Methods included from Helpers::MessagesHelper

#msg_customer_duplicated, #msg_customer_not_found, #msg_duplicated, #msg_not_found

Methods inherited from BaseInteractor

#repository, #success?

Constructor Details

#initialize(handler, data) ⇒ AddQuantity

Returns a new instance of AddQuantity.



13
14
15
16
# File 'lib/lita/interactors/add_quantity.rb', line 13

def initialize(handler, data)
  @handler = handler
  @data = data
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



10
11
12
# File 'lib/lita/interactors/add_quantity.rb', line 10

def data
  @data
end

Instance Method Details

#performObject



18
19
20
21
22
23
24
25
# File 'lib/lita/interactors/add_quantity.rb', line 18

def perform
  if service_exists?
    update_costumer_if_exist
  else
    @error = msg_not_found(service_name: name)
  end
  self
end