Class: Interage::ApplicationService

Inherits:
Object
  • Object
show all
Defined in:
lib/interage/application_service.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ ApplicationService

Returns a new instance of ApplicationService.



21
22
23
# File 'lib/interage/application_service.rb', line 21

def initialize(args = {})
  args.each { |key, value| set_private_ivar(key, value) }
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



5
6
7
# File 'lib/interage/application_service.rb', line 5

def errors
  @errors
end

Class Method Details

.call(**args) ⇒ Object

Call your service

Example:

Foo.call(arg1: 1, arg2: 2)

Arguments:

args: (Hash)

Return:

perform's return


17
18
19
# File 'lib/interage/application_service.rb', line 17

def self.call(**args)
  new(args).perform
end

Instance Method Details

#performObject

Implement this method to run your service

Raises:

  • (NotImplementedError)


26
27
28
29
# File 'lib/interage/application_service.rb', line 26

def perform
  raise NotImplementedError,
        "Please implement 'perform' method in your #{self.class.name}"
end

#success?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/interage/application_service.rb', line 31

def success?
  errors.blank?
end