Class: Light::Services::Base

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

Instance Attribute Summary collapse

Attributes included from Outputs

#outputs

Attributes included from Parameters

#parameters

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Callbacks

included

Methods included from Outputs

included

Methods included from Parameters

included

Constructor Details

#initialize(args = {}) ⇒ Base

Returns a new instance of Base.



14
15
16
17
18
19
20
21
22
# File 'lib/light/services/base.rb', line 14

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



12
13
14
# File 'lib/light/services/base.rb', line 12

def errors
  @errors
end

#warningsObject (readonly)

Getters



12
13
14
# File 'lib/light/services/base.rb', line 12

def warnings
  @warnings
end

Class Method Details

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



37
38
39
# File 'lib/light/services/base.rb', line 37

def call(args = {})
  new(args).tap(&:call)
end

Instance Method Details

#any_warnings?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/light/services/base.rb', line 32

def any_warnings?
  warnings.any?
end

#callObject



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

def call
  within_transaction { run_service }
end

#success?Boolean

Returns:

  • (Boolean)


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

def success?
  errors.blank?
end