summaryrefslogtreecommitdiffstats
path: root/lib/blink/objects.rb
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2005-04-14 04:49:28 +0000
committerLuke Kanies <luke@madstop.com>2005-04-14 04:49:28 +0000
commitc6755f5f30be79ddb42c0afc4d89be42a2df47f9 (patch)
tree0ff0ccc7d1b013680346bba10c7d5216ea693ad7 /lib/blink/objects.rb
parente5676ab347399a1f32e77bf4f64eaa73d54a895b (diff)
downloadpuppet-c6755f5f30be79ddb42c0afc4d89be42a2df47f9.tar.gz
puppet-c6755f5f30be79ddb42c0afc4d89be42a2df47f9.tar.xz
puppet-c6755f5f30be79ddb42c0afc4d89be42a2df47f9.zip
adding class collection and naming stuff
git-svn-id: https://reductivelabs.com/svn/puppet/library/trunk@149 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/blink/objects.rb')
-rw-r--r--lib/blink/objects.rb49
1 files changed, 40 insertions, 9 deletions
diff --git a/lib/blink/objects.rb b/lib/blink/objects.rb
index 14ecd92b5..5d03dc1aa 100644
--- a/lib/blink/objects.rb
+++ b/lib/blink/objects.rb
@@ -5,7 +5,11 @@
require 'blink/attribute'
require 'blink/interface'
-puts Blink.class
+#---------------------------------------------------------------
+# This class is the abstract base class for the mechanism for organizing
+# work. No work is actually done by this class or its subclasses; rather,
+# the subclasses include attributes which do the actual work.
+# See attribute.rb for how work is actually done.
module Blink
class Objects < Blink::Interface
@@ -13,7 +17,9 @@ module Blink
@objects = Hash.new
@@allobjects = Array.new # and then an array for all objects
- @@types = Hash.new { |hash,key|
+
+ @@typeary = []
+ @@typehash = Hash.new { |hash,key|
raise "Object type %s not found" % key
}
@@ -24,11 +30,28 @@ module Blink
# all objects total
def Objects.push(object)
@@allobjects.push object
- Blink.debug("adding %s of type %s to master list" % [object.name,object.class])
+ Blink.debug("adding %s of type %s to master list" %
+ [object.name,object.class])
end
#-----------------------------------
#-----------------------------------
+ # this is meant to be run multiple times, e.g., when a new
+ # type is defined at run-time
+ def Objects.buildtypehash
+ @@typeary.each { |otype|
+ if @@typehash.include?(otype.name)
+ if @@typehash[otype.name] != otype
+ Blink.warning("Object type %s is already defined" % otype.name)
+ end
+ else
+ @@typehash[otype.name] = otype
+ end
+ }
+ end
+ #-----------------------------------
+
+ #-----------------------------------
# this should make it so our subclasses don't have to worry about
# defining these class instance variables
def Objects.inherited(sub)
@@ -37,16 +60,23 @@ module Blink
@actions = Hash.new
}
- if @@types.include?(sub.name)
- Blink.notice("Redefining object type %s" % sub.name)
- else
- #Blink.debug("Defining object type %s" % sub.name)
- end
- @@types[sub.name] = sub
+ # add it to the master list
+ # unfortunately we can't yet call sub.name, because the #inherited
+ # method gets called before any commands in the class definition
+ # get executed, which, um, sucks
+ @@typeary.push(sub)
end
#-----------------------------------
#-----------------------------------
+ # this is used for mapping object types (e.g., Blink::Objects::File)
+ # to names (e.g., "file")
+ def Objects.name
+ return @name
+ end
+ #-----------------------------------
+
+ #-----------------------------------
# some simple stuff to make it easier to get a name from everyone
def Objects.namevar
return @namevar
@@ -264,6 +294,7 @@ module Blink
# this is a wrapper, doing all of the work that should be done
# and none that shouldn't
def evaluate
+ raise "don't call evaluate; it's disabled"
end
#-----------------------------------