You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
instance_variables changes return type between 1.8 and 1.9
The return type of `instance_variables` changes between Ruby 1.8 and 1.9
releases; it used to return an array of strings in the form "@foo", but
now returns an array of symbols in the form :@foo.
Nothing else in the stack cares which form you get - you can pass the
string or symbol to things like `instance_variable_set` and they will work
transparently.
Having the same form in all releases of Puppet is a win, though, so we
pick a unification and enforce than on all releases. That way developers
who do set math on them (eg: for YAML rendering) don't have to handle the
distinction themselves.
In the sane tradition, we bring older releases into conformance with newer
releases, so we return symbols rather than strings, to be more like the
future versions of Ruby are.
We also carefully support reloading, by only wrapping when we don't
already have the original version of the method aliased away somewhere.
This includes a second monkey-patch, on the `resolv` library that ships with
Ruby 1.8. This is the only bit of code in the core stack that made
assumptions about the return format of names from `instance_methods`.
Specifically, it assumed they were strings, and could be evaluated using
`instance_eval` to fetch out the value. The fix is to replace that with a
call to `instance_variable_get` which, like it does in Ruby 1.9, avoids the
cost of eval parsing as well as being more robust overall.
I did audit the rest of the standard library on 1.8.5 and 1.8.7 to verify
this. We only need worry if we start using the SOAP or Tk support.
Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
0 commit comments