Class: ServiceIt::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/service_it/base.rb

Overview

Inherit this class and implement perform method

Documentation:

https://github.com/iago-silva/service_it

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Base



23
24
25
# File 'lib/service_it/base.rb', line 23

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

Class Method Details

.call(**args) ⇒ Object

Call your service

Example:

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

Arguments:

args: (Hash)

Return:

perform's return


19
20
21
# File 'lib/service_it/base.rb', line 19

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

Instance Method Details

#performObject

Implement this method to run your service

Raises:

  • (NotImplementedError)


28
29
30
31
# File 'lib/service_it/base.rb', line 28

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