summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDaniel Pittman <daniel@puppetlabs.com>2011-03-31 13:36:19 -0700
committerDaniel Pittman <daniel@puppetlabs.com>2011-04-04 10:19:53 -0700
commitc52261c7aa86e7e75f215ba0f6b8c140003c4ead (patch)
tree44bde94c0581934e59ca9b989e21c0fd63333f69 /lib
parent1635454755fa8fdc0dedf032c543d3f4006aa568 (diff)
downloadpuppet-c52261c7aa86e7e75f215ba0f6b8c140003c4ead.tar.gz
puppet-c52261c7aa86e7e75f215ba0f6b8c140003c4ead.tar.xz
puppet-c52261c7aa86e7e75f215ba0f6b8c140003c4ead.zip
(#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@puppetlabs.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/string/action.rb37
1 files changed, 34 insertions, 3 deletions
diff --git a/lib/puppet/string/action.rb b/lib/puppet/string/action.rb
index 692e467b4..9e82f4d5d 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)