Skip to content

Commit

Permalink
(PDK-1209) Fix the other call-sites of const_defined? and const_get
Browse files Browse the repository at this point in the history
Same as #132, there are more const_get and const_defined? calls that
need to ignore inherited names.
  • Loading branch information
DavidS committed Oct 25, 2018
1 parent 1b6b654 commit 5cb89ed
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions lib/puppet/resource_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -543,16 +543,16 @@ def load_provider(type_name)
def load_default_provider(class_name, type_name_sym)
# loads the "puppet/provider/#{type_name}/#{type_name}" file through puppet
Puppet::Type.type(type_name_sym).provider(type_name_sym)
Puppet::Provider.const_get(class_name).const_get(class_name)
Puppet::Provider.const_get(class_name, false).const_get(class_name, false)
end
module_function :load_default_provider # rubocop:disable Style/AccessModifierDeclarations

def load_device_provider(class_name, type_name_sym, device_class_name, device_name_sym)
# loads the "puppet/provider/#{type_name}/#{device_name}" file through puppet
Puppet::Type.type(type_name_sym).provider(device_name_sym)
provider_module = Puppet::Provider.const_get(class_name)
if provider_module.const_defined?(device_class_name)
provider_module.const_get(device_class_name)
provider_module = Puppet::Provider.const_get(class_name, false)
if provider_module.const_defined?(device_class_name, false)
provider_module.const_get(device_class_name, false)
else
load_default_provider(class_name, type_name_sym)
end
Expand Down
2 changes: 1 addition & 1 deletion spec/puppet/resource_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
end

describe Puppet::Provider do
it('has a module prepared for the provider') { expect(described_class.const_get('Minimal').name).to eq 'Puppet::Provider::Minimal' }
it('has a module prepared for the provider') { expect(described_class.const_get('Minimal', false).name).to eq 'Puppet::Provider::Minimal' }
end
end

Expand Down

0 comments on commit 5cb89ed

Please sign in to comment.