Class: Lita::Interactors::AddAll

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

Overview

Increases all customers’ quantity with the given value or with 1 if nothing is specified.

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) ⇒ AddAll

Returns a new instance of AddAll.



14
15
16
17
# File 'lib/lita/interactors/add_all.rb', line 14

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

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



11
12
13
# File 'lib/lita/interactors/add_all.rb', line 11

def data
  @data
end

Instance Method Details

#performObject



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

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