Class: OpenWFE::GenericSyncExpression::MergeArray
- Inherits:
-
Object
- Object
- OpenWFE::GenericSyncExpression::MergeArray
- Includes:
- MergeMixin
- Defined in:
- lib/openwfe/expressions/fe_concurrence.rb
Overview
This inner class is used to gather workitems (via push()) before the final merge This final merge is triggered by calling the do_merge() method which will return the resulting, merged workitem.
Instance Attribute Summary collapse
-
#merge ⇒ Object
Returns the value of attribute merge.
-
#merge_type ⇒ Object
Returns the value of attribute merge_type.
-
#synchable_fei ⇒ Object
Returns the value of attribute synchable_fei.
-
#workitem ⇒ Object
Returns the value of attribute workitem.
-
#workitems_by_altitude ⇒ Object
Returns the value of attribute workitems_by_altitude.
-
#workitems_by_arrival ⇒ Object
Returns the value of attribute workitems_by_arrival.
Instance Method Summary collapse
-
#do_merge ⇒ Object
merges the workitems stored here.
-
#initialize(synchable_fei, merge, merge_type) ⇒ MergeArray
constructor
A new instance of MergeArray.
- #push(synchable, wi) ⇒ Object
- #push_by_arrival(wi) ⇒ Object
- #push_by_position(wi) ⇒ Object
- #push_in_isolation(wi) ⇒ Object
Methods included from MergeMixin
Constructor Details
#initialize(synchable_fei, merge, merge_type) ⇒ MergeArray
Returns a new instance of MergeArray.
510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 |
# File 'lib/openwfe/expressions/fe_concurrence.rb', line 510 def initialize (synchable_fei, merge, merge_type) @synchable_fei = synchable_fei @merge = merge @merge_type = merge_type ensure_merge_settings @workitem = nil if highest? or lowest? @workitems_by_arrival = [] @workitems_by_altitude = [] end end |
Instance Attribute Details
#merge ⇒ Object
Returns the value of attribute merge.
502 503 504 |
# File 'lib/openwfe/expressions/fe_concurrence.rb', line 502 def merge @merge end |
#merge_type ⇒ Object
Returns the value of attribute merge_type.
502 503 504 |
# File 'lib/openwfe/expressions/fe_concurrence.rb', line 502 def merge_type @merge_type end |
#synchable_fei ⇒ Object
Returns the value of attribute synchable_fei.
502 503 504 |
# File 'lib/openwfe/expressions/fe_concurrence.rb', line 502 def synchable_fei @synchable_fei end |
#workitem ⇒ Object
Returns the value of attribute workitem.
502 503 504 |
# File 'lib/openwfe/expressions/fe_concurrence.rb', line 502 def workitem @workitem end |
#workitems_by_altitude ⇒ Object
Returns the value of attribute workitems_by_altitude.
502 503 504 |
# File 'lib/openwfe/expressions/fe_concurrence.rb', line 502 def workitems_by_altitude @workitems_by_altitude end |
#workitems_by_arrival ⇒ Object
Returns the value of attribute workitems_by_arrival.
502 503 504 |
# File 'lib/openwfe/expressions/fe_concurrence.rb', line 502 def workitems_by_arrival @workitems_by_arrival end |
Instance Method Details
#do_merge ⇒ Object
merges the workitems stored here
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 |
# File 'lib/openwfe/expressions/fe_concurrence.rb', line 581 def do_merge return @workitem if @workitem list = if first? @workitems_by_arrival.reverse elsif last? @workitems_by_arrival elsif highest? @workitems_by_altitude.reverse elsif lowest? @workitems_by_altitude end result = nil list.each do |wi| next unless wi result = merge_workitems result, wi, override? end #puts "___ result :" #puts result.to_s #puts result end |
#push(synchable, wi) ⇒ Object
527 528 529 530 531 532 533 534 535 536 537 538 539 540 |
# File 'lib/openwfe/expressions/fe_concurrence.rb', line 527 def push (synchable, wi) #synchable.ldebug do # "push() isolate? #{isolate?}" #end if isolate? push_in_isolation wi elsif last? or first? push_by_position wi else push_by_arrival wi end end |
#push_by_arrival(wi) ⇒ Object
568 569 570 571 572 573 574 575 576 |
# File 'lib/openwfe/expressions/fe_concurrence.rb', line 568 def push_by_arrival (wi) #index = synchable.children.index wi.last_expression_id #index = Integer(wi.last_expression_id.child_id) index = Integer(get_child_id(wi)) @workitems_by_arrival << wi @workitems_by_altitude[index] = wi end |
#push_by_position(wi) ⇒ Object
542 543 544 545 546 547 548 549 550 |
# File 'lib/openwfe/expressions/fe_concurrence.rb', line 542 def push_by_position (wi) source, target = if first? [ @workitem, wi ] else [ wi, @workitem ] end @workitem = merge_workitems target, source, override? end |
#push_in_isolation(wi) ⇒ Object
552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 |
# File 'lib/openwfe/expressions/fe_concurrence.rb', line 552 def push_in_isolation (wi) unless @workitem @workitem = wi.dup att = @workitem.attributes @workitem.attributes = {} end #key = synchable.children.index wi.last_expression_id #key = wi.last_expression_id.child_id key = get_child_id wi @workitem.attributes[key.to_s] = OpenWFE::fulldup(wi.attributes) end |