Module: ConvenientService::Service::Plugins::CanHaveConnectedSteps::Concern
- Includes:
- ConvenientService::Support::Concern
- Defined in:
- lib/convenient_service/service/plugins/can_have_connected_steps/concern.rb
Class Method Summary collapse
- .and_group(&block) ⇒ ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::Expressions::Base
- .and_not_group(&block) ⇒ ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::Expressions::Base
-
.and_not_step(*args, **kwargs) ⇒ ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::Expressions::Base
Registers a negated step (step definition).
-
.and_step(*args, **kwargs) ⇒ ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::Expressions::Base
Registers a step (step definition).
- .group(&block) ⇒ ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::Expressions::Base
- .not_group(&block) ⇒ ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::Expressions::Base
-
.not_step(*args, **kwargs) ⇒ ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::Expressions::Base
Registers a negated step (step definition).
- .or_group(&block) ⇒ ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::Expressions::Base
- .or_not_group(&block) ⇒ ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::Expressions::Base
-
.or_not_step(*args, **kwargs) ⇒ ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::Expressions::Base
Registers a negated alternative step (step definition).
-
.or_step(*args, **kwargs) ⇒ ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::Expressions::Base
Registers an alternative step (step definition).
-
.step(*args, **kwargs) ⇒ ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::Expressions::Base
Registers a step (step definition).
- .steps ⇒ ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::StepCollection private
Instance Method Summary collapse
- #regular_result ⇒ ConvenientService::Service::Plugins::HasJSendResult::Entities::Result private
- #steps ⇒ ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::StepCollection
- #steps_result ⇒ ConvenientService::Service::Plugins::HasJSendResult::Entities::Result
Class Method Details
.and_group(&block) ⇒ ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::Expressions::Base
and
from and_group
has a similar precedence as Ruby's &&
.
group
from and_group
has a similar precedence as Ruby's ()
.
not_group
is a rought equivalent of && ()
.
It is NOT recommended to rely on the return value of this method, since it may differ across different step
related plugins.
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/concern.rb', line 301 def and_group(&block) previous_expression = steps.expression ::ConvenientService.raise Exceptions::FirstStepIsNotSet.new(container: self) if previous_expression.empty? steps.expression = Entities::Expressions::Empty.new block&.call current_expression = steps.expression ::ConvenientService.raise Exceptions::FirstGroupStepIsNotSet.new(container: self, method: __method__) if current_expression.empty? steps.expression = Entities::Expressions::And.new( previous_expression, Entities::Expressions::Group.new(current_expression) ) end |
.and_not_group(&block) ⇒ ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::Expressions::Base
and
from and_not_group
has a similar precedence as Ruby's &&
.
not
from and_not_group
has a similar precedence as Ruby's !
.
group
from and_not_group
has a similar precedence as Ruby's ()
.
and_not_group
is a rought equivalent of && !()
.
It is NOT recommended to rely on the return value of this method, since it may differ across different step
related plugins.
334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/concern.rb', line 334 def and_not_group(&block) previous_expression = steps.expression ::ConvenientService.raise Exceptions::FirstStepIsNotSet.new(container: self) if previous_expression.empty? steps.expression = Entities::Expressions::Empty.new block&.call current_expression = steps.expression ::ConvenientService.raise Exceptions::FirstGroupStepIsNotSet.new(container: self, method: __method__) if current_expression.empty? steps.expression = Entities::Expressions::And.new( previous_expression, Entities::Expressions::Not.new( Entities::Expressions::Group.new(current_expression) ) ) end |
.and_not_step(*args, **kwargs) ⇒ ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::Expressions::Base
and
from and_step
has a similar precedence as Ruby's &&
.
not
from and_not_step
has a similar precedence as Ruby's !
.
and_not_step
is a rought equivalent of && !step
.
It is NOT recommended to rely on the return value of this method, since it may differ across different step
related plugins.
Registers a negated step (step definition).
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/concern.rb', line 115 def and_not_step(*args, **kwargs) previous_expression = steps.expression ::ConvenientService.raise Exceptions::FirstStepIsNotSet.new(container: self) if previous_expression.empty? new_step = steps.create(*args, **kwargs) steps.expression = Entities::Expressions::And.new( previous_expression, Entities::Expressions::Not.new( Entities::Expressions::Scalar.new(new_step) ) ) end |
.and_step(*args, **kwargs) ⇒ ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::Expressions::Base
and
from and_step
has a similar precedence as Ruby's &&
.
and_step
is a rought equivalent of && step
.
It is NOT recommended to rely on the return value of this method, since it may differ across different step
related plugins.
Registers a step (step definition).
86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/concern.rb', line 86 def and_step(*args, **kwargs) previous_expression = steps.expression ::ConvenientService.raise Exceptions::FirstStepIsNotSet.new(container: self) if previous_expression.empty? new_step = steps.create(*args, **kwargs) steps.expression = Entities::Expressions::And.new( previous_expression, Entities::Expressions::Scalar.new(new_step) ) end |
.group(&block) ⇒ ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::Expressions::Base
group
has a similar precedence as Ruby's ()
.
group
is a rought equivalent of ()
.
It is NOT recommended to rely on the return value of this method, since it may differ across different step
related plugins.
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/concern.rb', line 229 def group(&block) previous_expression = steps.expression steps.expression = Entities::Expressions::Empty.new block&.call current_expression = steps.expression ::ConvenientService.raise Exceptions::FirstGroupStepIsNotSet.new(container: self, method: __method__) if current_expression.empty? steps.expression = if previous_expression.empty? Entities::Expressions::Group.new(current_expression) else Entities::Expressions::And.new( previous_expression, Entities::Expressions::Group.new(current_expression) ) end end |
.not_group(&block) ⇒ ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::Expressions::Base
not
from not_group
has a similar precedence as Ruby's !
.
group
from not_group
has a similar precedence as Ruby's ()
.
not_group
is a rought equivalent of !()
.
It is NOT recommended to rely on the return value of this method, since it may differ across different step
related plugins.
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/concern.rb', line 263 def not_group(&block) previous_expression = steps.expression steps.expression = Entities::Expressions::Empty.new block&.call current_expression = steps.expression ::ConvenientService.raise Exceptions::FirstGroupStepIsNotSet.new(container: self, method: __method__) if current_expression.empty? steps.expression = if previous_expression.empty? Entities::Expressions::Not.new( Entities::Expressions::Group.new(current_expression) ) else Entities::Expressions::And.new( previous_expression, Entities::Expressions::Not.new( Entities::Expressions::Group.new(current_expression) ) ) end end |
.not_step(*args, **kwargs) ⇒ ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::Expressions::Base
not
from not_step
has a similar precedence as Ruby's !
.
not_step
is a rought equivalent of !step
.
It is NOT recommended to rely on the return value of this method, since it may differ across different step
related plugins.
Registers a negated step (step definition).
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/concern.rb', line 52 def not_step(*args, **kwargs) previous_expression = steps.expression new_step = steps.create(*args, **kwargs) steps.expression = if previous_expression.empty? Entities::Expressions::Not.new( Entities::Expressions::Scalar.new(new_step) ) else Entities::Expressions::And.new( previous_expression, Entities::Expressions::Not.new( Entities::Expressions::Scalar.new(new_step) ) ) end end |
.or_group(&block) ⇒ ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::Expressions::Base
or
from or_group
has a similar precedence as Ruby's ||
.
group
from or_group
has a similar precedence as Ruby's ()
.
or_group
is a rought equivalent of || ()
It is NOT recommended to rely on the return value of this method, since it may differ across different step
related plugins.
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/concern.rb', line 371 def or_group(&block) previous_expression = steps.expression ::ConvenientService.raise Exceptions::FirstStepIsNotSet.new(container: self) if previous_expression.empty? steps.expression = Entities::Expressions::Empty.new block&.call current_expression = steps.expression ::ConvenientService.raise Exceptions::FirstGroupStepIsNotSet.new(container: self, method: __method__) if current_expression.empty? steps.expression = if previous_expression.and? Entities::Expressions::And.new( previous_expression.left_expression, Entities::Expressions::Or.new( previous_expression.right_expression, Entities::Expressions::Group.new(current_expression) ) ) else Entities::Expressions::Or.new( previous_expression, Entities::Expressions::Group.new(current_expression) ) end end |
.or_not_group(&block) ⇒ ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::Expressions::Base
or
from or_not_group
has a similar precedence as Ruby's ||
.
not
from or_not_group
has a similar precedence as Ruby's !
.
group
from or_not_group
has a similar precedence as Ruby's ()
.
or_not_group
is a rought equivalent of || !()
It is NOT recommended to rely on the return value of this method, since it may differ across different step
related plugins.
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/concern.rb', line 417 def or_not_group(&block) previous_expression = steps.expression ::ConvenientService.raise Exceptions::FirstStepIsNotSet.new(container: self) if previous_expression.empty? steps.expression = Entities::Expressions::Empty.new block&.call current_expression = steps.expression ::ConvenientService.raise Exceptions::FirstGroupStepIsNotSet.new(container: self, method: __method__) if current_expression.empty? steps.expression = if previous_expression.and? Entities::Expressions::And.new( previous_expression.left_expression, Entities::Expressions::Or.new( previous_expression.right_expression, Entities::Expressions::Not.new( Entities::Expressions::Group.new(current_expression) ) ) ) else Entities::Expressions::Or.new( previous_expression, Entities::Expressions::Not.new( Entities::Expressions::Group.new(current_expression) ) ) end end |
.or_not_step(*args, **kwargs) ⇒ ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::Expressions::Base
or
from or_not_step
has a similar precedence as Ruby's ||
.
not
from or_not_step
has a similar precedence as Ruby's !
.
or_not_step
is a rought equivalent of || !step
.
It is NOT recommended to rely on the return value of this method, since it may differ across different step
related plugins.
Registers a negated alternative step (step definition).
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/concern.rb', line 190 def or_not_step(*args, **kwargs) previous_expression = steps.expression ::ConvenientService.raise Exceptions::FirstStepIsNotSet.new(container: self) if previous_expression.empty? new_step = steps.create(*args, **kwargs) steps.expression = if previous_expression.and? Entities::Expressions::And.new( previous_expression.left_expression, Entities::Expressions::Or.new( previous_expression.right_expression, Entities::Expressions::Not.new( Entities::Expressions::Scalar.new(new_step) ) ) ) else Entities::Expressions::Or.new( previous_expression, Entities::Expressions::Not.new( Entities::Expressions::Scalar.new(new_step) ) ) end end |
.or_step(*args, **kwargs) ⇒ ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::Expressions::Base
or
from or_step
has a similar precedence as Ruby's ||
.
or_step
is a rought equivalent of || step
.
It is NOT recommended to rely on the return value of this method, since it may differ across different step
related plugins.
Registers an alternative step (step definition).
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/concern.rb', line 148 def or_step(*args, **kwargs) previous_expression = steps.expression ::ConvenientService.raise Exceptions::FirstStepIsNotSet.new(container: self) if previous_expression.empty? new_step = steps.create(*args, **kwargs) steps.expression = if previous_expression.and? Entities::Expressions::And.new( previous_expression.left_expression, Entities::Expressions::Or.new( previous_expression.right_expression, Entities::Expressions::Scalar.new(new_step) ) ) else Entities::Expressions::Or.new( previous_expression, Entities::Expressions::Scalar.new(new_step) ) end end |
.step(*args, **kwargs) ⇒ ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::Expressions::Base
It is NOT recommended to rely on the return value of this method, since it may differ across different step
related plugins.
Registers a step (step definition).
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/concern.rb', line 22 def step(*args, **kwargs) previous_expression = steps.expression new_step = steps.create(*args, **kwargs) steps.expression = if previous_expression.empty? Entities::Expressions::Scalar.new(new_step) else Entities::Expressions::And.new( previous_expression, Entities::Expressions::Scalar.new(new_step) ) end end |
.steps ⇒ ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::StepCollection
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
456 457 458 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/concern.rb', line 456 def steps internals_class.cache.fetch(:steps) { Entities::StepCollection.new(container: self) } end |
Instance Method Details
#regular_result ⇒ ConvenientService::Service::Plugins::HasJSendResult::Entities::Result
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
471 472 473 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/concern.rb', line 471 def regular_result(...) result_without_middlewares(...) end |
#steps ⇒ ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::StepCollection
May be useful for debugging purposes.
steps
are frozen.
486 487 488 489 490 491 492 493 494 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/concern.rb', line 486 def steps internals.cache.fetch(:steps) do self.class .steps .tap(&:commit!) .with_organizer(self) .tap(&:commit!) end end |
#steps_result ⇒ ConvenientService::Service::Plugins::HasJSendResult::Entities::Result
500 501 502 503 504 505 506 507 508 509 510 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/concern.rb', line 500 def steps_result ::ConvenientService.raise Exceptions::ServiceHasNoSteps.new(service_class: self.class) if steps.none? steps.each_evaluated_step do |step| step.save_outputs_in_organizer! step.mark_as_completed! end steps.result end |