summaryrefslogtreecommitdiffstats
path: root/lib/blink/interface.rb
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2005-04-18 19:48:27 +0000
committerLuke Kanies <luke@madstop.com>2005-04-18 19:48:27 +0000
commita48963907943e403efda745573d4b553691a4854 (patch)
treef192cb66962d3262b657a3d58458958508de0c6b /lib/blink/interface.rb
parent14c23083cc342c12b1bd6ffa437691884d2ac782 (diff)
downloadpuppet-a48963907943e403efda745573d4b553691a4854.tar.gz
puppet-a48963907943e403efda745573d4b553691a4854.tar.xz
puppet-a48963907943e403efda745573d4b553691a4854.zip
moving some methods around
git-svn-id: https://reductivelabs.com/svn/puppet/library/trunk@175 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/blink/interface.rb')
-rw-r--r--lib/blink/interface.rb120
1 files changed, 71 insertions, 49 deletions
diff --git a/lib/blink/interface.rb b/lib/blink/interface.rb
index 7e19c9798..660e9bd7d 100644
--- a/lib/blink/interface.rb
+++ b/lib/blink/interface.rb
@@ -23,6 +23,54 @@ module Blink
# this is a bit of a hack, but it'll work for now
attr_accessor :performoperation
+ attr_writer :noop
+
+ #---------------------------------------------------------------
+ # retrieve a named object
+ def Interface.[](name)
+ if @objects.has_key?(name)
+ return @objects[name]
+ else
+ raise "Object '#{name}' does not exist"
+ end
+ end
+ #---------------------------------------------------------------
+
+ #---------------------------------------------------------------
+ # this is special, because it can be equivalent to running new
+ # this allows cool syntax like Blink::File["/etc/inetd.conf"] = ...
+ def Interface.[]=(name,object)
+ newobj = nil
+ if object.is_a?(Blink::Interface)
+ newobj = object
+ else
+ raise "must pass a Blink::Interface object"
+ end
+
+ if @objects.has_key?(newobj.name)
+ puts @objects
+ raise "'#{newobj.name}' already exists in " +
+ "class '#{newobj.class}': #{@objects[newobj.name]}"
+ else
+ #Blink.debug("adding %s of type %s to class list" %
+ # [object.name,object.class])
+ @objects[newobj.name] = newobj
+ end
+ end
+ #---------------------------------------------------------------
+
+ #---------------------------------------------------------------
+ def Interface.has_key?(name)
+ return @objects.has_key?(name)
+ end
+ #---------------------------------------------------------------
+
+ #---------------------------------------------------------------
+ # a left-recursive path again?
+ def change(ary)
+
+ end
+ #---------------------------------------------------------------
#---------------------------------------------------------------
def evaluate
@@ -39,25 +87,9 @@ module Blink
#---------------------------------------------------------------
#---------------------------------------------------------------
- # set up the "interface" methods
- [:sync,:retrieve].each { |method|
- self.send(:define_method,method) {
- self.each { |subobj|
- #Blink.debug("sending '%s' to '%s'" % [method,subobj])
- subobj.send(method)
- }
- }
- }
- #---------------------------------------------------------------
-
- #---------------------------------------------------------------
- def presync
- self.each { |contained|
- # this gets right to the heart of our question:
- # do all subclasses of Interface contain all of their
- # content in contained objects?
- Blink::Modification.new(contained)
- }
+ # return the full path to us, for logging and rollback
+ def fqpath
+ return self.class, self.name
end
#---------------------------------------------------------------
@@ -79,42 +111,32 @@ module Blink
#---------------------------------------------------------------
#---------------------------------------------------------------
- # retrieve a named object
- def Interface.[](name)
- if @objects.has_key?(name)
- return @objects[name]
- else
- raise "Object '#{name}' does not exist"
- end
- end
+ # should we actually do anything?
+ def noop
+ return self.noop || Blink[:noop] || false
+ end
#---------------------------------------------------------------
#---------------------------------------------------------------
- # this is special, because it can be equivalent to running new
- # this allows cool syntax like Blink::File["/etc/inetd.conf"] = ...
- def Interface.[]=(name,object)
- newobj = nil
- if object.is_a?(Blink::Interface)
- newobj = object
- else
- raise "must pass a Blink::Interface object"
- end
-
- if @objects.has_key?(newobj.name)
- puts @objects
- raise "'#{newobj.name}' already exists in " +
- "class '#{newobj.class}': #{@objects[newobj.name]}"
- else
- #Blink.debug("adding %s of type %s to class list" %
- # [object.name,object.class])
- @objects[newobj.name] = newobj
- end
- end
+ # set up the "interface" methods
+ [:sync,:retrieve].each { |method|
+ self.send(:define_method,method) {
+ self.each { |subobj|
+ #Blink.debug("sending '%s' to '%s'" % [method,subobj])
+ subobj.send(method)
+ }
+ }
+ }
#---------------------------------------------------------------
#---------------------------------------------------------------
- def Interface.has_key?(name)
- return @objects.has_key?(name)
+ def presync
+ self.each { |contained|
+ # this gets right to the heart of our question:
+ # do all subclasses of Interface contain all of their
+ # content in contained objects?
+ Blink::Modification.new(contained)
+ }
end
#---------------------------------------------------------------
end