Class: Ruote::Mutation
- Inherits:
-
Object
- Object
- Ruote::Mutation
- Defined in:
- lib/ruote/dboard/mutation.rb
Overview
A set of mutation points.
Initialized by Ruote::Dashboard#compute_mutation
Instance Attribute Summary collapse
-
#points ⇒ Object
readonly
Returns the value of attribute points.
-
#ps ⇒ Object
readonly
ProcessStatus instance (advanced stuff).
Instance Method Summary collapse
-
#apply(option = nil) ⇒ Object
Applies the mutation, :update points first then :re_apply points.
-
#initialize(dboard, wfid, tree) ⇒ Mutation
constructor
A new instance of Mutation.
- #to_a ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(dboard, wfid, tree) ⇒ Mutation
Returns a new instance of Mutation.
90 91 92 93 94 95 96 97 98 99 |
# File 'lib/ruote/dboard/mutation.rb', line 90 def initialize(dboard, wfid, tree) @dboard = dboard @points = [] @ps = @dboard.ps(wfid) walk(@ps.root_expression, Ruote.compact_tree(tree)) @points = @points.sort_by { |point| point.fei.expid } end |
Instance Attribute Details
#points ⇒ Object (readonly)
Returns the value of attribute points.
88 89 90 |
# File 'lib/ruote/dboard/mutation.rb', line 88 def points @points end |
#ps ⇒ Object (readonly)
ProcessStatus instance (advanced stuff).
86 87 88 |
# File 'lib/ruote/dboard/mutation.rb', line 86 def ps @ps end |
Instance Method Details
#apply(option = nil) ⇒ Object
Applies the mutation, :update points first then :re_apply points.
Accepts an option, nil means apply all, :update means apply only update mutations points, :re_apply means apply on re_apply points, :force_update means apply all but turn re_apply points into update points.
120 121 122 123 124 125 126 127 128 |
# File 'lib/ruote/dboard/mutation.rb', line 120 def apply(option=nil) updates, re_applies = @points.partition { |pt| pt.type == :update } points = updates + re_applies points.each { |pt| pt.apply(@dboard, option) } self end |
#to_a ⇒ Object
101 102 103 104 105 106 |
# File 'lib/ruote/dboard/mutation.rb', line 101 def to_a @points.collect { |pt| { 'fei' => pt.fei, 'action' => pt.type, 'tree' => pt.tree } } end |
#to_s ⇒ Object
108 109 110 111 |
# File 'lib/ruote/dboard/mutation.rb', line 108 def to_s @points.collect(&:to_s).join("\n") end |