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).
- .else_group(*args, **kwargs, &block) ⇒ Object
- .elsif_not_step_group(*args, **kwargs, &block) ⇒ Object
- .elsif_step_group(*args, **kwargs, &block) ⇒ Object
- .group(&block) ⇒ ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::Expressions::Base
- .if_not_step_group(*args, **kwargs, &block) ⇒ Object
-
.if_step_group(*args, **kwargs, &block) ⇒ Object
or_if_step_group.
- .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
-
#step(*args, **kwargs) ⇒ ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step
Registers a step (step definition).
- #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.
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/concern.rb', line 306 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.
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/concern.rb', line 339 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).
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/concern.rb', line 120 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).
91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/concern.rb', line 91 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 |
.else_group(*args, **kwargs, &block) ⇒ Object
614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/concern.rb', line 614 def else_group(*args, **kwargs, &block) previous_expression = steps.expression ::ConvenientService.raise Exceptions::FirstStepIsNotSet.new(container: self) if previous_expression.empty? ::ConvenientService.raise Exceptions::FirstGroupStepIsNotSet.new(container: self, method: __method__) unless previous_expression.complex_if? 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::ComplexIf.new( [ *previous_expression.if_expressions ], Entities::Expressions::Else.new(current_expression) ) end |
.elsif_not_step_group(*args, **kwargs, &block) ⇒ Object
580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/concern.rb', line 580 def elsif_not_step_group(*args, **kwargs, &block) previous_expression = steps.expression ::ConvenientService.raise Exceptions::FirstStepIsNotSet.new(container: self) if previous_expression.empty? ::ConvenientService.raise Exceptions::FirstGroupStepIsNotSet.new(container: self, method: __method__) unless previous_expression.complex_if? new_step = steps.create(*args, **kwargs) 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::ComplexIf.new( [ *previous_expression.if_expressions, Entities::Expressions::If.new( Entities::Expressions::Not.new( Entities::Expressions::Scalar.new(new_step) ), current_expression ) ] ) end |
.elsif_step_group(*args, **kwargs, &block) ⇒ Object
545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/concern.rb', line 545 def elsif_step_group(*args, **kwargs, &block) # require "debug"; binding.break previous_expression = steps.expression ::ConvenientService.raise Exceptions::FirstStepIsNotSet.new(container: self) if previous_expression.empty? # `and` or `or`. # ::ConvenientService.raise Exceptions::FirstGroupStepIsNotSet.new(container: self, method: __method__) unless previous_expression.complex_if? new_step = steps.create(*args, **kwargs) 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::ComplexIf.new( [ *previous_expression.if_expressions, Entities::Expressions::If.new( Entities::Expressions::Scalar.new(new_step), current_expression ) ] ) 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.
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/concern.rb', line 234 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 |
.if_not_step_group(*args, **kwargs, &block) ⇒ Object
500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/concern.rb', line 500 def if_not_step_group(*args, **kwargs, &block) previous_expression = steps.expression new_step = steps.create(*args, **kwargs) 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::ComplexIf.new( [ Entities::Expressions::If.new( Entities::Expressions::Not.new( Entities::Expressions::Scalar.new(new_step) ), current_expression ) ] ) else Entities::Expressions::And.new( previous_expression, Entities::Expressions::ComplexIf.new( [ Entities::Expressions::If.new( Entities::Expressions::Not.new( Entities::Expressions::Scalar.new(new_step) ), current_expression ) ] ) ) end end |
.if_step_group(*args, **kwargs, &block) ⇒ Object
or_if_step_group
459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/concern.rb', line 459 def if_step_group(*args, **kwargs, &block) previous_expression = steps.expression new_step = steps.create(*args, **kwargs) 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::ComplexIf.new( [ Entities::Expressions::If.new( Entities::Expressions::Scalar.new(new_step), current_expression ) ] ) else Entities::Expressions::And.new( previous_expression, Entities::Expressions::ComplexIf.new( [ Entities::Expressions::If.new( Entities::Expressions::Scalar.new(new_step), 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.
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/concern.rb', line 268 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).
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/concern.rb', line 57 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.
376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/concern.rb', line 376 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.
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 450 451 452 453 454 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/concern.rb', line 422 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).
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/concern.rb', line 195 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).
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/concern.rb', line 153 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).
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/concern.rb', line 27 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.
643 644 645 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/concern.rb', line 643 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.
658 659 660 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/concern.rb', line 658 def regular_result(...) result_without_middlewares(...) end |
#step(*args, **kwargs) ⇒ ConvenientService::Service::Plugins::CanHaveSteps::Entities::Step
Registers a step (step definition).
TODO: Dynamic expressions.
709 710 711 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/concern.rb', line 709 def step(*args, **kwargs) self.class.step_class.new(*args, **kwargs.merge(container: self.class, organizer: self, index: nil)) end |
#steps ⇒ ConvenientService::Service::Plugins::CanHaveConnectedSteps::Entities::StepCollection
May be useful for debugging purposes.
steps
are frozen.
673 674 675 676 677 678 679 680 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/concern.rb', line 673 def steps internals.cache.fetch(:steps) do self.class .steps .tap(&:commit!) .with_organizer(self) end end |
#steps_result ⇒ ConvenientService::Service::Plugins::HasJSendResult::Entities::Result
686 687 688 689 690 691 692 693 694 695 696 |
# File 'lib/convenient_service/service/plugins/can_have_connected_steps/concern.rb', line 686 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_evaluated! end steps.result end |