Skip to content

Commit

Permalink
Remove redundant wrapper method
Browse files Browse the repository at this point in the history
The is_constant_defined? method was added in 3d43d86 to account for
behavior differences between Ruby 1.8 and 1.9. It was simplified in
84a9cb8 as part of removal Ruby 1.8 support and the method exists now as
a fairly transparent wrapper of Ruby's built-in Module#const_defined?
method.

is_constant_defined? has been marked as private since 79889af in 2013.

This method removes the is_constant_defined? method and substitutes it
with Module#const_defined? instead.
  • Loading branch information
mhashizume committed Dec 12, 2023
1 parent c14dd55 commit 94366ad
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions lib/puppet/util/classgen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def genmodule(name, options = {}, &block)
def rmclass(name, options)
const = genconst_string(name, options)
retval = false
if is_constant_defined?(const)
if const_defined?(const, false)
remove_const(const)
retval = true
end
Expand Down Expand Up @@ -140,19 +140,13 @@ class << self
klass
end

# @api private
#
def is_constant_defined?(const)
const_defined?(const, false)
end

# Handle the setting and/or removing of the associated constant.
# @api private
#
def handleclassconst(klass, name, options)
const = genconst_string(name, options)

if is_constant_defined?(const)
if const_defined?(const, false)
if options[:overwrite]
Puppet.info _("Redefining %{name} in %{klass}") % { name: name, klass: self }
remove_const(const)
Expand Down

0 comments on commit 94366ad

Please sign in to comment.