Class: Lita::Handlers::Service
- Inherits:
-
Handler
- Object
- Handler
- Lita::Handlers::Service
- Defined in:
- lib/lita/handlers/service.rb
Overview
Handles all commands relative to the service
Instance Method Summary collapse
- #create(response) ⇒ Object
- #delete(response) ⇒ Object
- #list(response) ⇒ Object
-
#pong(response) ⇒ Object
Callbacks.
- #reply(template, message, response, interactor) ⇒ Object
- #show(response) ⇒ Object
Instance Method Details
#create(response) ⇒ Object
46 47 48 49 50 51 |
# File 'lib/lita/handlers/service.rb', line 46 def create(response) interactor = Interactors::CreateService.new(self, response.match_data).perform template = :service_created = { service: interactor. } reply(template, , response, interactor) end |
#delete(response) ⇒ Object
60 61 62 63 64 65 |
# File 'lib/lita/handlers/service.rb', line 60 def delete(response) interactor = Interactors::DeleteService.new(self, response.match_data).perform template = :message = { message: interactor. } reply(template, , response, interactor) end |
#list(response) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/lita/handlers/service.rb', line 39 def list(response) interactor = Interactors::ListServices.new(self, response.match_data).perform template = :list_services = { services: interactor. } reply(template, , response, interactor) end |
#pong(response) ⇒ Object
Callbacks
35 36 37 |
# File 'lib/lita/handlers/service.rb', line 35 def pong(response) response.reply 'pong!' end |
#reply(template, message, response, interactor) ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/lita/handlers/service.rb', line 67 def reply(template, , response, interactor) unless interactor.success? template = :error = { error: interactor.error } end response.reply(render_template(template, )) end |
#show(response) ⇒ Object
53 54 55 56 57 58 |
# File 'lib/lita/handlers/service.rb', line 53 def show(response) interactor = Interactors::ShowService.new(self, response.match_data).perform template = :service_show = { service: interactor. } reply(template, , response, interactor) end |