Class: Decouplio::LogicDsl
- Inherits:
-
Object
- Object
- Decouplio::LogicDsl
- Defined in:
- lib/decouplio/logic_dsl.rb
Constant Summary collapse
- DEFAULT_WRAP_NAME =
'wrap'
Class Attribute Summary collapse
-
.palps ⇒ Object
readonly
Returns the value of attribute palps.
-
.steps ⇒ Object
readonly
Returns the value of attribute steps.
Class Method Summary collapse
- .aide(_aide_class, **_options) ⇒ Object
- .doby(_doby_class, **_options) ⇒ Object
- .fail(stp, **options) ⇒ Object
- .inherited(subclass) ⇒ Object
- .init_steps ⇒ Object
- .octo(octo_name, **options, &block) ⇒ Object
- .palp(palp_name, **options, &block) ⇒ Object
- .pass(stp, **options) ⇒ Object
- .resq(name = :resq, **options) ⇒ Object
- .step(stp, **options) ⇒ Object
- .wrap(name = nil, **options, &block) ⇒ Object
Class Attribute Details
.palps ⇒ Object (readonly)
Returns the value of attribute palps.
20 21 22 |
# File 'lib/decouplio/logic_dsl.rb', line 20 def palps @palps end |
.steps ⇒ Object (readonly)
Returns the value of attribute steps.
20 21 22 |
# File 'lib/decouplio/logic_dsl.rb', line 20 def steps @steps end |
Class Method Details
.aide(_aide_class, **_options) ⇒ Object
136 137 138 |
# File 'lib/decouplio/logic_dsl.rb', line 136 def aide(_aide_class, **) raise '"aide" step is deprecated. Please use "fail". Just simply replace "aide " with "fail "' end |
.doby(_doby_class, **_options) ⇒ Object
131 132 133 134 |
# File 'lib/decouplio/logic_dsl.rb', line 131 def doby(_doby_class, **) raise '"doby" step is deprecated. Please use "step" or "pass" instead. ' \ 'Just simply replace "doby " with "step " or "pass "' end |
.fail(stp, **options) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/decouplio/logic_dsl.rb', line 50 def fail(stp, **) raise Decouplio::Errors::FailCanNotBeFirstStepError if @steps.empty? if stp.is_a?(Class) && !(stp < Decouplio::Action) = {} .each_key do |key| [key] = .delete(key) if Decouplio::Const::StepOptions::ALLOWED.include?(key) end @steps << { type: Decouplio::Const::Types::FAIL_TYPE, name: stp, _args: , ** } else @steps << .merge(type: Decouplio::Const::Types::FAIL_TYPE, name: stp) end end |
.inherited(subclass) ⇒ Object
22 23 24 |
# File 'lib/decouplio/logic_dsl.rb', line 22 def inherited(subclass) subclass.init_steps end |
.init_steps ⇒ Object
26 27 28 29 |
# File 'lib/decouplio/logic_dsl.rb', line 26 def init_steps @steps = [] @palps = {} end |
.octo(octo_name, **options, &block) ⇒ Object
89 90 91 92 93 94 95 96 97 98 |
# File 'lib/decouplio/logic_dsl.rb', line 89 def octo(octo_name, **, &block) raise Decouplio::Errors::OctoBlockIsNotDefinedError unless block_given? hash_case = Class.new(Decouplio::OctoHashCase, &block).hash_case raise Decouplio::Errors::OctoBlockIsNotDefinedError if hash_case.empty? [:hash_case] = hash_case @steps << .merge(type: Decouplio::Const::Types::OCTO_TYPE, name: octo_name) end |
.palp(palp_name, **options, &block) ⇒ Object
100 101 102 103 104 105 106 |
# File 'lib/decouplio/logic_dsl.rb', line 100 def palp(palp_name, **, &block) raise Decouplio::Errors::PalpBlockIsNotDefinedError unless block_given? .empty? || raise(Decouplio::Errors::PalpValidationError) @palps[palp_name] = Class.new(self, &block) end |
.pass(stp, **options) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/decouplio/logic_dsl.rb', line 70 def pass(stp, **) if stp.is_a?(Class) && !(stp < Decouplio::Action) = {} .each_key do |key| [key] = .delete(key) if Decouplio::Const::StepOptions::ALLOWED.include?(key) end @steps << { type: Decouplio::Const::Types::PASS_TYPE, name: stp, _args: , ** } else @steps << .merge(type: Decouplio::Const::Types::PASS_TYPE, name: stp) end end |
.resq(name = :resq, **options) ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/decouplio/logic_dsl.rb', line 108 def resq(name = :resq, **) unless Decouplio::Const::Types::MAIN_FLOW_TYPES.include?(@steps.last&.[](:type)) raise Decouplio::Errors::ResqDefinitionError end @steps << { name: name, type: Decouplio::Const::Types::RESQ_TYPE, step_to_resq: @steps.delete(@steps.last), handler_hash: } end |
.step(stp, **options) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/decouplio/logic_dsl.rb', line 31 def step(stp, **) if stp.is_a?(Class) && !(stp < Decouplio::Action) = {} .each_key do |key| [key] = .delete(key) if Decouplio::Const::StepOptions::ALLOWED.include?(key) end @steps << { type: Decouplio::Const::Types::STEP_TYPE, name: stp, _args: , ** } else @steps << .merge(type: Decouplio::Const::Types::STEP_TYPE, name: stp) end end |
.wrap(name = nil, **options, &block) ⇒ Object
121 122 123 124 125 126 127 128 129 |
# File 'lib/decouplio/logic_dsl.rb', line 121 def wrap(name = nil, **, &block) raise Decouplio::Errors::WrapBlockIsNotDefinedError unless block_given? @steps << .merge( type: Decouplio::Const::Types::WRAP_TYPE, name: name, wrap_flow: block ) end |