From c45c5c4fff877c3d13af2ba9a5db94fa16a5473c Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Wed, 13 Apr 2005 18:20:25 +0000 Subject: renaming git-svn-id: https://reductivelabs.com/svn/puppet/library/trunk@110 980ebf18-57e1-0310-9a29-db15c13687c0 --- lib/blink/function.rb | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 lib/blink/function.rb (limited to 'lib/blink/function.rb') diff --git a/lib/blink/function.rb b/lib/blink/function.rb new file mode 100644 index 000000000..66620c514 --- /dev/null +++ b/lib/blink/function.rb @@ -0,0 +1,41 @@ +#!/usr/local/bin/ruby -w + +# $Id$ + +require 'blink' +require 'blink/fact' + +module Blink + class Function + @@functions = Hash.new(nil) + + #--------------------------------------------------------------- + def [](name) + return @@functions[name] + end + #--------------------------------------------------------------- + + #--------------------------------------------------------------- + def call(*args) + @code.call(*args) + end + #--------------------------------------------------------------- + + #--------------------------------------------------------------- + # we want a 'proc' item instead of a block, so that we can return + # from it + def initialize(name,code) + @name = name + @code = code + + @@functions[name] = self + end + #--------------------------------------------------------------- + end + + Function.new("retrieve", proc { |fact| + require 'blink/fact' + + return Fact[fact] + }) +end -- cgit