Last active
August 29, 2015 14:27
-
-
Save branan/1f8a1d953926c40e5b43 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'uri' | |
module Puppet | |
newtype(:uri_provider) do | |
@doc = "A type which determines its provider based on the scheme of a URI passed as a parameter" | |
ensurable | |
newparam(:name) do | |
end | |
newparam(:uri) do | |
desc "The URI we should attempt to provide for" | |
end | |
def self.fixup_default_provider | |
@paramhash[:provider].defaultto { | |
uri = URI(@resource[:uri]) | |
uri.scheme | |
} | |
end | |
# Normally providify gets called automatically when a | |
# provider is added for a type. We call it explicitly | |
# here so that we know for sure that the parameter | |
# exists before we try to change it. | |
providify | |
fixup_default_provider | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment