summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--state.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/state.rb b/state.rb
index b842184..6f232c9 100644
--- a/state.rb
+++ b/state.rb
@@ -85,6 +85,11 @@ class State
end
end
+ # Puts the class name and parameters
+ def to_s
+ "#{self.class.name}#{params.inspect} (#{@active ? "up" : "down"})"
+ end
+
# Hold this state. Holding a state informs the system that you would like it
# to come up or remain up. +hold+ can be an object of type Hold, an object of
# type State to establish that said state depends on this one, or one of
@@ -138,6 +143,9 @@ class State
self.hash == other.hash
end
+ # eql? is the same as ==
+ alias :eql? :==
+
# Match this State object to patterns or other State objects
def ===(other)
return other === self if other.is_a? StatePattern
@@ -271,6 +279,14 @@ class Hold
self.class == other.class
end
+ # eql? is the same as ==
+ def eql?(other); self == other; end
+
+ # The default to_s just prints the type of hold
+ def to_s
+ self.class.name
+ end
+
# A hold placed when the system has an interest in something being running
class System < Hold; end
# A hold placed when the user has asked for something to be running
@@ -291,6 +307,11 @@ class Hold
@dependent.drop
end
+ # Prints the state who has this hold
+ def to_s
+ "hold by #{@dependent}"
+ end
+
# Two Dep holds are equal if they have the same dependent
def ==(other)
return other == @dependent if other.is_a? State