[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, experimental, updated. debian/2.6.8-1-844-g7ec39d5
Daniel Pittman
daniel at puppetlabs.com
Tue May 10 08:10:43 UTC 2011
The following commit has been merged in the experimental branch:
commit c52261c7aa86e7e75f215ba0f6b8c140003c4ead
Author: Daniel Pittman <daniel at puppetlabs.com>
Date: Thu Mar 31 13:36:19 2011 -0700
(#6749) disable Action#invoke for this release.
So, we have Action#invoke, but it binds to the declaring class, not to the
correct instance. Solving all the subtle issues around threads, global state,
and bindings without causing us too much pain is actually pretty hard, so
instead we pull the feature.
It can be enabled again in a future release and, being a strict extension
feature, we can do that without overly hurting anyone. We still have full
access to the invocation through a marginally less pleasant syntax, but one
that people MUST be able to arrange to allow invoke to work, so on that front
we are clean.
Reviewed-By: Pieter van de Bruggen <pieter at puppetlabs.com>
diff --git a/lib/puppet/string/action.rb b/lib/puppet/string/action.rb
index 692e467..9e82f4d 100644
--- a/lib/puppet/string/action.rb
+++ b/lib/puppet/string/action.rb
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
require 'puppet/string'
require 'puppet/string/option'
@@ -16,9 +17,39 @@ class Puppet::String::Action
attrs.each do |k,v| send("#{k}=", v) end
end
- def invoke(*args, &block)
- @string.method(name).call(*args,&block)
- end
+ # Initially, this was defined to allow the @action.invoke pattern, which is
+ # a very natural way to invoke behaviour given our introspection
+ # capabilities. Heck, our initial plan was to have the string delegate to
+ # the action object for invocation and all.
+ #
+ # It turns out that we have a binding problem to solve: @string was bound to
+ # the parent class, not the subclass instance, and we don't pass the
+ # appropriate context or change the binding enough to make this work.
+ #
+ # We could hack around it, by either mandating that you pass the context in
+ # to invoke, or try to get the binding right, but that has probably got
+ # subtleties that we don't instantly think of – especially around threads.
+ #
+ # So, we are pulling this method for now, and will return it to life when we
+ # have the time to resolve the problem. For now, you should replace...
+ #
+ # @action = @string.get_action(name)
+ # @action.invoke(arg1, arg2, arg3)
+ #
+ # ...with...
+ #
+ # @action = @string.get_action(name)
+ # @string.send(@action.name, arg1, arg2, arg3)
+ #
+ # I understand that is somewhat cumbersome, but it functions as desired.
+ # --daniel 2011-03-31
+ #
+ # PS: This code is left present, but commented, to support this chunk of
+ # documentation, for the benefit of the reader.
+ #
+ # def invoke(*args, &block)
+ # @string.send(name, *args, &block)
+ # end
def invoke=(block)
if @string.is_a?(Class)
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list