summaryrefslogtreecommitdiffstats
path: root/state.rb
diff options
context:
space:
mode:
authorCasey Dahlin <cdahlin@redhat.com>2008-10-08 15:01:29 -0400
committerCasey Dahlin <cdahlin@redhat.com>2008-10-08 15:16:45 -0400
commit77c1ab4d6d490e0e348690eda061b07e9bb98e4f (patch)
tree3765ccfbe447897f83f797987b9118cc7b5301fb /state.rb
parent9870591732ebb419e1130fb1a9cca6bce8e908c1 (diff)
downloadupstate-77c1ab4d6d490e0e348690eda061b07e9bb98e4f.tar.gz
upstate-77c1ab4d6d490e0e348690eda061b07e9bb98e4f.tar.xz
upstate-77c1ab4d6d490e0e348690eda061b07e9bb98e4f.zip
Rename StatePattern to Dependency
StatePattern is now called Dependency
Diffstat (limited to 'state.rb')
-rw-r--r--state.rb33
1 files changed, 17 insertions, 16 deletions
diff --git a/state.rb b/state.rb
index b27e3f2..ccfe132 100644
--- a/state.rb
+++ b/state.rb
@@ -51,7 +51,8 @@ class State
@@states = Set.new # Set of activatable states
@@state_types = Set.new # Set of state types
- # Create a new state. +deps+ is a list of State objects, not patterns
+ # Create a new state. +deps+ is a list of State objects, not Dependency
+ # objects
def initialize(deps)
raise NoMethodError if self.class == State
@@ -174,9 +175,9 @@ class State
# eql? is the same as ==
alias :eql? :==
- # Match this State object to patterns or other State objects
+ # Match this State object to Dependencies or other State objects
def ===(other)
- return other === self if other.is_a? StatePattern
+ return other === self if other.is_a? Dependency
return self == other
end
@@ -195,7 +196,7 @@ class State
end
# Create a new type of state. +name+ is capitalized and postfixed with "State"
- # to create the new state class name. +depends+ is a series of StatePattern
+ # to create the new state class name. +depends+ is a series of Dependency
# Objects. This method is not defined in subclasses of State.
def State.new_type(name, caused_by, depends)
name = name.capitalize + "State"
@@ -360,13 +361,13 @@ class Hold
end
=begin rdoc
-A StatePattern is a notion of a state which might exist. It will contain the
-type of the state and perhaps some sort of patterns which certain parameters
-must conform to, but it does not necessarily contain enough info to define a
-state in its entirety.
+A Dependency is a notion of a state which might satisfy the needs of another
+state. It will contain the type of the state and perhaps some sort of patterns
+which certain parameters must conform to, but it does not necessarily contain
+enough info to define a state in its entirety.
=end
-class StatePattern
- # A state pattern is created from a class of state to match, and a hash of
+class Dependency
+ # A dependency is created from a class of state to match, and a hash of
# parameters. The parameters in the hash can be string values to match or
# Regex objects
def initialize(stateclass, params = {})
@@ -376,20 +377,20 @@ class StatePattern
@params = params
end
- # Two state patterns are equal if any given set would be either matched
- # by both or rejected by both
+ # Two dependencies are equal if any given set would be either matched by both
+ # or rejected by both
def ==(other)
- return false unless other.is_a? StatePattern
+ return false unless other.is_a? Dependency
return(other.stateclass == @stateclass and other.params == params)
end
- # Tests for equality between state patterns or matching between a state
- # pattern and a state
+ # Tests for equality between dependencies or matching between a dependency and
+ # a state
def ===(other)
return(self.match(other) or self == other)
end
- # Determines if a state matches this pattern
+ # Determines if a state meets this dependency
def match(other)
return false unless other.is_a? @stateclass
return false if (@params.keys - other.params.keys).size > 0