summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser/functions/realize.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet/parser/functions/realize.rb')
-rw-r--r--lib/puppet/parser/functions/realize.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/puppet/parser/functions/realize.rb b/lib/puppet/parser/functions/realize.rb
new file mode 100644
index 000000000..1bdde234e
--- /dev/null
+++ b/lib/puppet/parser/functions/realize.rb
@@ -0,0 +1,14 @@
+# This is just syntactic sugar for a collection, although it will generally
+# be a good bit faster.
+
+Puppet::Parser::Functions::newfunction(:realize, :doc => "Make a virtual object real. This is useful
+ when you want to know the name of the virtual object and don't want to
+ bother with a full collection. It is slightly faster than a collection,
+ and, of course, is a bit shorter. You must pass the object using a
+ reference; e.g.: ``realize User[luke]``." ) do |vals|
+ coll = Puppet::Parser::Collector.new(self, :nomatter, nil, nil, :virtual)
+ vals = [vals] unless vals.is_a?(Array)
+ coll.resources = vals
+
+ compiler.add_collection(coll)
+end