summaryrefslogtreecommitdiffstats
path: root/lib/puppet/util/rdoc/code_objects.rb
diff options
context:
space:
mode:
authorMatt Robinson <matt@puppetlabs.com>2011-03-22 22:28:27 -0700
committerMatt Robinson <matt@puppetlabs.com>2011-03-23 13:10:34 -0700
commit3d43d866d6629863d91861f29638c1a31750ba57 (patch)
tree27ed7cb89e50c22dc418d769d755b3ae8bb16538 /lib/puppet/util/rdoc/code_objects.rb
parentad85b67ade99a3ec4ed4a8e578c9d288706b567d (diff)
downloadpuppet-3d43d866d6629863d91861f29638c1a31750ba57.tar.gz
puppet-3d43d866d6629863d91861f29638c1a31750ba57.tar.xz
puppet-3d43d866d6629863d91861f29638c1a31750ba57.zip
(#2782) Fix constant_defined?
Thanks to Al Hoang for the bit of code for choosing how to use constant_defined? depending on the version of Ruby. In Ruby 1.9 const_defined? has a new parameter for inherit (from Ruby docs) mod.const_defined?(sym, inherit=true) -> true or false Returns true if a constant with the given name is defined by mod, or its ancestors if inherit is not false. Unfortunately, the documentation isn't terribly clear about the behavior if inherit=false. In Ruby 1.8 the inherit parameter doesn't exist. It appears that setting inherit=false makes it behave like it used to in Ruby 1.8, but there may be sublties of autoloading that prove this wrong or ways in which were setting constants that changed and cause problems regardless of the behavior of const_defined? Ruby 1.8.7: irb(main):001:0> module Foo irb(main):002:1> end => nil irb(main):003:0> A = 'find_me?' => "find_me?" irb(main):004:0> Foo.const_defined?('A') => false Ruby 1.9.2: ruby-1.9.2-p136 :001 > module Foo ruby-1.9.2-p136 :002?> end => nil ruby-1.9.2-p136 :003 > A = 'find_me?' => "find_me?" ruby-1.9.2-p136 :004 > Foo.const_defined?('A') => true ruby-1.9.2-p136 :005 > Foo.const_defined?('A', false) => false Also noteworthy is that something about constants behavior changed between 1.9.1 and 1.9.2, though not in regard to the little test above, but we should only be testing against 1.9.2 anyway. At least with this change in we'll be able to start debugging test failures instead of just getting failures at the level of syntax errors. Reviewed-by: Jacob Helwig <jacob@puppetlabs.com>
Diffstat (limited to 'lib/puppet/util/rdoc/code_objects.rb')
0 files changed, 0 insertions, 0 deletions