Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(PDK-1209) Fix the other call-sites of const_defined? and const_get #134

Merged
merged 1 commit into from
Oct 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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