summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2005-04-14 04:56:53 +0000
committerLuke Kanies <luke@madstop.com>2005-04-14 04:56:53 +0000
commit67fae6d13151bec7204a6b7da5ade609a869ee9b (patch)
tree6f52d800d60d667751e395e89c650239bf6b726c
parentb4bb6807843187f35dd2313fa3dd5e7220dcaa01 (diff)
downloadpuppet-67fae6d13151bec7204a6b7da5ade609a869ee9b.tar.gz
puppet-67fae6d13151bec7204a6b7da5ade609a869ee9b.tar.xz
puppet-67fae6d13151bec7204a6b7da5ade609a869ee9b.zip
updates
git-svn-id: https://reductivelabs.com/svn/puppet/library/trunk@151 980ebf18-57e1-0310-9a29-db15c13687c0
-rw-r--r--lib/blink/objects.rb42
1 files changed, 41 insertions, 1 deletions
diff --git a/lib/blink/objects.rb b/lib/blink/objects.rb
index 5d03dc1aa..4e5f9b268 100644
--- a/lib/blink/objects.rb
+++ b/lib/blink/objects.rb
@@ -12,7 +12,7 @@ require 'blink/interface'
# See attribute.rb for how work is actually done.
module Blink
- class Objects < Blink::Interface
+ class Objects
include Enumerable
@objects = Hash.new
@@allobjects = Array.new # and then an array for all objects
@@ -26,6 +26,46 @@ module Blink
#---------------------------------------------------------------
# the class methods
+ #---------------------------------------------------------------
+ # retrieve a named object
+ def Objects.[](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 Objects.[]=(name,object)
+ newobj = nil
+ if object.is_a?(Blink::Objects)
+ newobj = object
+ else
+ raise "must pass a Blink::Objects 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 Objects.has_key?(name)
+ return @objects.has_key?(name)
+ end
+ #---------------------------------------------------------------
+
#-----------------------------------
# all objects total
def Objects.push(object)