summaryrefslogtreecommitdiffstats
path: root/lib/puppet/statechange.rb
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-02-27 22:21:44 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-02-27 22:21:44 +0000
commit8c821c09eebe117bd8b100b6dc416ded0588b979 (patch)
treeaacd4fb7d966eae215917e5556e9e08eeb43bc53 /lib/puppet/statechange.rb
parent37c10d176d8d3b7bb1920bbda66c6f0429b66730 (diff)
downloadpuppet-8c821c09eebe117bd8b100b6dc416ded0588b979.tar.gz
puppet-8c821c09eebe117bd8b100b6dc416ded0588b979.tar.xz
puppet-8c821c09eebe117bd8b100b6dc416ded0588b979.zip
Mostly, this is a refactoring commit. There is one significant new feature,
though: overrides now only work within a class heirarchy, which is to say that a subclass can override an element in a base class, but a child scope cannot otherwise override an element in a base scope. I've also done a good bit of refactoring, though; notably, AST#evaluate now takes named arguments, and I changed the 'name' parameter to 'type' in all of the Component classes (this was all internal, but was confusing as it was). I also removed the need for the autonaming stuff -- it's now acceptable for components not to have names, and everything behaves correctly. I haven't yet removed the autoname code, though; I'll do that on the next commit. git-svn-id: https://reductivelabs.com/svn/puppet/trunk@952 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet/statechange.rb')
-rw-r--r--lib/puppet/statechange.rb15
1 files changed, 5 insertions, 10 deletions
diff --git a/lib/puppet/statechange.rb b/lib/puppet/statechange.rb
index b77931c4e..5fdf407d2 100644
--- a/lib/puppet/statechange.rb
+++ b/lib/puppet/statechange.rb
@@ -3,10 +3,11 @@
# enables no-op and logging/rollback
module Puppet
+ # Handle all of the work around performing an actual change,
+ # including calling 'sync' on the states and producing events.
class StateChange
attr_accessor :is, :should, :type, :path, :state, :transaction, :changed
- #---------------------------------------------------------------
def initialize(state)
@state = state
@path = [state.path,"change"].flatten
@@ -21,9 +22,9 @@ module Puppet
@changed = false
end
- #---------------------------------------------------------------
- #---------------------------------------------------------------
+ # Perform the actual change. This method can go either forward or
+ # backward, and produces an event.
def go
if @state.insync?
@state.info "Already in sync"
@@ -99,9 +100,7 @@ module Puppet
)
end
end
- #---------------------------------------------------------------
- #---------------------------------------------------------------
def forward
#@state.debug "moving change forward"
@@ -113,9 +112,8 @@ module Puppet
return self.go
end
- #---------------------------------------------------------------
- #---------------------------------------------------------------
+ # Switch the goals of the state, thus running the change in reverse.
def backward
@state.should = @is
@state.retrieve
@@ -137,13 +135,10 @@ module Puppet
#raise "Moving statechanges backward is currently unsupported"
#@type.change(@path,@should,@is)
end
- #---------------------------------------------------------------
- #---------------------------------------------------------------
def noop
return @state.noop
end
- #---------------------------------------------------------------
def to_s
return "change %s.%s(%s)" %