diff options
author | Luke Kanies <luke@madstop.com> | 2005-04-14 22:00:47 +0000 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2005-04-14 22:00:47 +0000 |
commit | 6140bee579c92cb89fc91ff8514a7796202a28fb (patch) | |
tree | 0fe22542b757e288726e006b3ac00390bed2c423 | |
parent | d94d7a3223b896ab9d1502955e0cf6bb492e8773 (diff) | |
download | puppet-6140bee579c92cb89fc91ff8514a7796202a28fb.tar.gz puppet-6140bee579c92cb89fc91ff8514a7796202a28fb.tar.xz puppet-6140bee579c92cb89fc91ff8514a7796202a28fb.zip |
making fact a real type
git-svn-id: https://reductivelabs.com/svn/puppet/library/trunk@161 980ebf18-57e1-0310-9a29-db15c13687c0
-rw-r--r-- | lib/blink/fact.rb | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/lib/blink/fact.rb b/lib/blink/fact.rb index 90dc0de54..4da297828 100644 --- a/lib/blink/fact.rb +++ b/lib/blink/fact.rb @@ -9,9 +9,14 @@ # currently a very thin veneer on 'facter' require 'facter' +require 'blink/types' module Blink - class Fact + class Fact < Blink::Interface + def Fact.[](name) + Facter[name].value + end + # just pass the block to 'add' # the block has to do things like set the interpreter, # the code (which can be a ruby block), and maybe the @@ -20,8 +25,29 @@ module Blink Facter[name].add(&block) end - def Fact.[](name) - Facter[name].value + def Fact.name + return :fact + end + + def Fact.namevar + return :name + end + + Blink::Types.newtype(self) + + def initialize(hash) + name = hash[:name] + hash.delete(:name) + Fact.add(name) { |fact| + p fact + hash.each { |key,value| + method = key + "=" + #if key.is_a?(String) + # key = key.intern + #end + fact.send(method,value) + } + } end end end |