Class: SimpleLogicStep::Service
- Inherits:
-
Object
- Object
- SimpleLogicStep::Service
- Defined in:
- lib/simple_logic_step.rb
Overview
Copy from here
Instance Attribute Summary collapse
-
#ctx ⇒ Object
readonly
Returns the value of attribute ctx.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#semantic ⇒ Object
readonly
Returns the value of attribute semantic.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
- #failure? ⇒ Boolean
-
#initialize(**ctx) ⇒ Service
constructor
A new instance of Service.
-
#process ⇒ Object
Implement business logic here.
- #success? ⇒ Boolean
Constructor Details
#initialize(**ctx) ⇒ Service
Returns a new instance of Service.
14 15 16 17 18 19 |
# File 'lib/simple_logic_step.rb', line 14 def initialize(**ctx) @success = true @semantic = nil @ctx = ctx @message = nil end |
Instance Attribute Details
#ctx ⇒ Object (readonly)
Returns the value of attribute ctx.
8 9 10 |
# File 'lib/simple_logic_step.rb', line 8 def ctx @ctx end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
8 9 10 |
# File 'lib/simple_logic_step.rb', line 8 def @message end |
#semantic ⇒ Object (readonly)
Returns the value of attribute semantic.
8 9 10 |
# File 'lib/simple_logic_step.rb', line 8 def semantic @semantic end |
Class Method Details
.call(**ctx) ⇒ Object
10 11 12 |
# File 'lib/simple_logic_step.rb', line 10 def self.call(**ctx) new(**ctx).call end |
Instance Method Details
#call ⇒ Object
21 22 23 24 25 |
# File 'lib/simple_logic_step.rb', line 21 def call prepare process self end |
#failure? ⇒ Boolean
32 33 34 35 36 37 38 |
# File 'lib/simple_logic_step.rb', line 32 def failure? if block_given? yield(self) unless success else !success end end |
#process ⇒ Object
Implement business logic here
28 29 30 |
# File 'lib/simple_logic_step.rb', line 28 def process raise 'Not implemented' end |
#success? ⇒ Boolean
40 41 42 43 44 45 46 |
# File 'lib/simple_logic_step.rb', line 40 def success? if block_given? yield(self) if success else success end end |