On Tue, Jul 15, 2008 at 12:36 AM, Daniel Pittman <[EMAIL PROTECTED]>
wrote:
> So, while I am happy to implement a solution to this I can see only a
> limited number of relatively undesirable options:
>
> 1. I can contort my define to take arguments that don't conflict with
> any Ruby method, ever, and do the same to my callers.
>
> 2. I can contort my define to rebind all arguments with a prefix, to
> avoid the conflict. This roughly doubles my line count for a trivial
> configuration file wrapper, which is painful.
>
I would probably deal with this today by doing 1, instead of anything else.
Neither of those is terrible appealing, though the second is at least
> theoretically future-proof. Not much fun, though.
>
> There is also option 3, which I would be happy to work on implementing:
>
> 3. Expose puppet variables to ERB through some mechanism other than
> implementing missing_method, so they are the closest lexical scope
> value found.
I've done a bit of digging in the template class, and I think you might be
able to refactor it thusly:
Look up all the variables in @scope, and turn them in to instance_variables
of the template wrapper class. This would let you do:
<%= @operatingsystem == "foo" %>
Instead of the current
<%= @operatingsystem == "foo" %>
If you really want to have local variables, we could do the same thing
within a lambda, and use that as the binding:
<%= operatingsystem == "foo" %>
That would eliminate the need for the method_missing entirely.
You'll be looking in templatewrapper.rb, and @scope is in scope.rb.
Something like, and this is from the top of my head, in templatewrapper.rb:
@scope.each_variable do |k|
self.instance_variable_set("@#{k}".to_sym, @scope.lookupvar(k))
end
Would do the trick for @variable.
Adam
--
HJK Solutions - We Launch Startups - http://www.hjksolutions.com
Adam Jacob, Senior Partner
T: (206) 508-4759 E: [EMAIL PROTECTED]
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Puppet Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/puppet-dev?hl=en
-~----------~----~----~----~------~----~------~--~---