Class: Lita::Interactors::CreateService

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

Overview

Create a new service with the given data, validating does not exist any service with the same name

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

Returns a new instance of CreateService.



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

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/create_service.rb', line 11

def data
  @data
end

Instance Method Details

#performObject



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

def perform
  if service_exists?
    @error = msg_duplicated(service_name: name)
  else
    @message = create_service
  end
  self
end