summaryrefslogtreecommitdiffstats
path: root/lib/blink/function.rb
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2005-04-15 20:09:07 +0000
committerLuke Kanies <luke@madstop.com>2005-04-15 20:09:07 +0000
commit3904d2efd505fec08de3c4e8e7ab6d14586aed7e (patch)
tree44f211e5d548037f5f1ff98289273edd09ac898f /lib/blink/function.rb
parent13f16b6690224758706e1c68d1da577a13df8be5 (diff)
downloadpuppet-3904d2efd505fec08de3c4e8e7ab6d14586aed7e.tar.gz
puppet-3904d2efd505fec08de3c4e8e7ab6d14586aed7e.tar.xz
puppet-3904d2efd505fec08de3c4e8e7ab6d14586aed7e.zip
fixing most of the function call stuff
git-svn-id: https://reductivelabs.com/svn/puppet/library/trunk@167 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/blink/function.rb')
-rw-r--r--lib/blink/function.rb37
1 files changed, 34 insertions, 3 deletions
diff --git a/lib/blink/function.rb b/lib/blink/function.rb
index 9e67b0071..4f10fb2c6 100644
--- a/lib/blink/function.rb
+++ b/lib/blink/function.rb
@@ -16,8 +16,8 @@ module Blink
#---------------------------------------------------------------
#---------------------------------------------------------------
- def call(*args)
- @code.call(*args)
+ def call(args)
+ @code.call(args)
end
#---------------------------------------------------------------
@@ -36,6 +36,37 @@ module Blink
Function.new("retrieve", proc { |fact|
require 'blink/fact'
- return Fact[fact]
+ value = Fact[fact]
+ Blink.debug("retrieved %s as %s" % [fact,value])
+ value
+ })
+
+ Function.new("addfact", proc { |args|
+ require 'blink/fact'
+ #Blink.debug("running addfact")
+
+ hash = nil
+ if args.is_a?(Array)
+ hash = Hash[*args]
+ end
+ name = nil
+ if hash.has_key?("name")
+ name = hash["name"]
+ hash.delete("name")
+ elsif hash.has_key?(:name)
+ name = hash[:name]
+ hash.delete(:name)
+ else
+ raise "Functions must have names"
+ end
+ #Blink.debug("adding fact %s" % name)
+ newfact = Fact.add(name) { |fact|
+ hash.each { |key,value|
+ method = key + "="
+ fact.send(method,value)
+ }
+ }
+
+ #Blink.debug("got fact %s" % newfact)
})
end