Class: Light::Services::Base

Inherits:
Object
  • Object
show all
Includes:
Callbacks, Parameters
Defined in:
lib/light/services/base.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Callbacks

included

Methods included from Parameters

included, #outputs, #parameters

Constructor Details

#initialize(args = {}) ⇒ Base

Returns a new instance of Base.



11
12
13
14
15
16
17
18
19
# File 'lib/light/services/base.rb', line 11

def initialize(args = {})
  @args = args

  initialize_params
  initialize_outputs

  @errors   = Light::Services::Messages.new
  @warnings = Light::Services::Messages.new
end

Instance Attribute Details

#errorsObject (readonly)

Getters



9
10
11
# File 'lib/light/services/base.rb', line 9

def errors
  @errors
end

#warningsObject (readonly)

Getters



9
10
11
# File 'lib/light/services/base.rb', line 9

def warnings
  @warnings
end

Class Method Details

.call(args = {}) ⇒ Object Also known as: run



34
35
36
37
38
# File 'lib/light/services/base.rb', line 34

def call(args = {})
  service = new(args)
  service.call
  service
end

Instance Method Details

#any_warnings?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/light/services/base.rb', line 29

def any_warnings?
  warnings.any?
end

#callObject



21
22
23
# File 'lib/light/services/base.rb', line 21

def call
  run_service
end

#success?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/light/services/base.rb', line 25

def success?
  errors.blank?
end