Created
April 4, 2013 15:13
-
-
Save asquelt/5311251 to your computer and use it in GitHub Desktop.
This file contains 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
class Hiera | |
class Scope | |
attr_reader :real | |
def initialize(real) | |
@real = real | |
end | |
def [](key) | |
if @real.resource.to_s.slice(0..4) == 'Class' | |
r = @real.resource.name.to_s.downcase | |
else | |
r = @real.resource.to_s.downcase | |
end | |
if key == "calling_class" | |
ans = r | |
elsif key == "calling_module" | |
ans = r.split("::").first | |
else | |
ans = @real.lookupvar(key) | |
end | |
# damn you puppet visual basic style variables. | |
return nil if ans == "" | |
return ans | |
end | |
def include?(key) | |
return true if ["calling_class", "calling_module"].include?(key) | |
return @real.lookupvar(key) != "" | |
end | |
def catalog | |
@real.catalog | |
end | |
def resource | |
@real.resource | |
end | |
def compiler | |
@real.compiler | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment