Class: SteppedService::Base

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#resultObject (readonly)

Returns the value of attribute result.



87
88
89
# File 'lib/stepped_service/base.rb', line 87

def result
  @result
end

Class Method Details

.call(*args, **keyword_args) ⇒ Object



89
90
91
# File 'lib/stepped_service/base.rb', line 89

def self.call(*args, **keyword_args)
  new(*args, **keyword_args).call
end

Instance Method Details

#callObject

You can override it, to not use steps



94
95
96
97
98
99
100
101
102
103
104
# File 'lib/stepped_service/base.rb', line 94

def call
  @finished = false
  @failed = false

  steps.each do |step|
    send(step)
    return self if finished? || failed?
  end
  finish!
  self
end

#errorsObject



123
124
125
126
# File 'lib/stepped_service/base.rb', line 123

def errors
  # use with errors.add(:network, e.message)
  @errors ||= Errors.new
end

#failure?Boolean Also known as: failed?

Returns:

  • (Boolean)


118
119
120
# File 'lib/stepped_service/base.rb', line 118

def failure?
  failed == true
end

#finished?Boolean

Returns:

  • (Boolean)


110
111
112
# File 'lib/stepped_service/base.rb', line 110

def finished?
  finished == true
end

#stepsObject



106
107
108
# File 'lib/stepped_service/base.rb', line 106

def steps
  %i[need to be implemented]
end

#success?Boolean

Returns:

  • (Boolean)


114
115
116
# File 'lib/stepped_service/base.rb', line 114

def success?
  !failure?
end