From 6140bee579c92cb89fc91ff8514a7796202a28fb Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Thu, 14 Apr 2005 22:00:47 +0000 Subject: making fact a real type git-svn-id: https://reductivelabs.com/svn/puppet/library/trunk@161 980ebf18-57e1-0310-9a29-db15c13687c0 --- lib/blink/fact.rb | 32 +++++++++++++++++++++++++++++--- 1 file 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 -- cgit