Class: Ruote::Mutation

Inherits:
Object
  • Object
show all
Defined in:
lib/ruote/dboard/mutation.rb

Overview

A set of mutation points.

Initialized by Ruote::Dashboard#compute_mutation

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#pointsObject (readonly)

Returns the value of attribute points


88
89
90
# File 'lib/ruote/dboard/mutation.rb', line 88

def points
  @points
end

#psObject (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_aObject


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_sObject


108
109
110
111
# File 'lib/ruote/dboard/mutation.rb', line 108

def to_s

  @points.collect(&:to_s).join("\n")
end