Class: Lita::Handlers::Service

Inherits:
Handler
  • Object
show all
Defined in:
lib/lita/handlers/service.rb

Overview

Handles all commands relative to the service

Instance Method Summary collapse

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
  message = { service: interactor.message }
  reply(template, message, 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 = { message: interactor.message }
  reply(template, message, 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
  message = { services: interactor.message }
  reply(template, message, 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, message, response, interactor)
  unless interactor.success?
    template = :error
    message = { error: interactor.error }
  end
  response.reply(render_template(template, message))
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
  message = { service: interactor.message }
  reply(template, message, response, interactor)
end