Class: Lita::Handlers::Customer
- Inherits:
-
Handler
- Object
- Handler
- Lita::Handlers::Customer
- Defined in:
- lib/lita/handlers/customer.rb
Overview
Handles all commands related to the customer
Class Method Summary collapse
Instance Method Summary collapse
- #add(response) ⇒ Object
- #add_all(response) ⇒ Object
- #change_value(response) ⇒ Object
- #delete_customer(response) ⇒ Object
-
#inscribe(response) ⇒ Object
Callbacks.
- #reply(template, message, response, interactor) ⇒ Object
- #reset(response) ⇒ Object
Class Method Details
.template_root ⇒ Object
8 9 10 |
# File 'lib/lita/handlers/customer.rb', line 8 def self.template_root File.('../../../templates', __dir__) end |
Instance Method Details
#add(response) ⇒ Object
58 59 60 61 62 63 |
# File 'lib/lita/handlers/customer.rb', line 58 def add(response) interactor = Interactors::AddQuantity.new(self, response.match_data).perform template = :message = { message: interactor. } reply(template, , response, interactor) end |
#add_all(response) ⇒ Object
65 66 67 68 69 70 |
# File 'lib/lita/handlers/customer.rb', line 65 def add_all(response) interactor = Interactors::AddAll.new(self, response.match_data).perform template = :message = { message: interactor. } reply(template, , response, interactor) end |
#change_value(response) ⇒ Object
51 52 53 54 55 56 |
# File 'lib/lita/handlers/customer.rb', line 51 def change_value(response) interactor = Interactors::ChangeValue.new(self, response.match_data).perform template = :message = { message: interactor. } reply(template, , response, interactor) end |
#delete_customer(response) ⇒ Object
79 80 81 82 83 84 |
# File 'lib/lita/handlers/customer.rb', line 79 def delete_customer(response) interactor = Interactors::DeleteCustomer.new(self, response.match_data).perform template = :message = { message: interactor. } reply(template, , response, interactor) end |
#inscribe(response) ⇒ Object
Callbacks
44 45 46 47 48 49 |
# File 'lib/lita/handlers/customer.rb', line 44 def inscribe(response) interactor = Interactors::InscribeCustomer.new(self, response.match_data).perform template = :message = { message: interactor. } reply(template, , response, interactor) end |
#reply(template, message, response, interactor) ⇒ Object
86 87 88 89 90 91 92 |
# File 'lib/lita/handlers/customer.rb', line 86 def reply(template, , response, interactor) unless interactor.success? template = :error = { error: interactor.error } end response.reply(render_template(template, )) end |
#reset(response) ⇒ Object
72 73 74 75 76 77 |
# File 'lib/lita/handlers/customer.rb', line 72 def reset(response) interactor = Interactors::ResetQuantity.new(self, response.match_data).perform template = :message = { message: interactor. } reply(template, , response, interactor) end |