Sha256: 38d3d9a97a6f1a5f6060eea9161ad363a603dc1c461b62c79cf738c17adf85dd

Contents?: true

Size: 1.06 KB

Versions: 90

Compression:

Stored size: 1.06 KB

Contents

class Hiera
  class Scope
    CALLING_CLASS = "calling_class"
    CALLING_MODULE = "calling_module"
    MODULE_NAME = "module_name"

    attr_reader :real

    def initialize(real)
      @real = real
    end

    def [](key)
      if key == CALLING_CLASS
        ans = find_hostclass(@real)
      elsif key == CALLING_MODULE
        ans = @real.lookupvar(MODULE_NAME)
      else
        ans = @real.lookupvar(key)
      end

      if ans.nil? or ans == ""
        nil
      else
        ans
      end
    end

    def include?(key)
      if key == CALLING_CLASS or key == CALLING_MODULE
        true
      else
        @real.lookupvar(key) != ""
      end
    end

    def catalog
      @real.catalog
    end

    def resource
      @real.resource
    end

    def compiler
      @real.compiler
    end

    def find_hostclass(scope)
      if scope.source and scope.source.type == :hostclass
        return scope.source.name.downcase
      elsif scope.parent
        return find_hostclass(scope.parent)
      else
        return nil
      end
    end
    private :find_hostclass
  end
end

Version data entries

90 entries across 90 versions & 2 rubygems

Version Path
puppet-retrospec-0.12.2 vendor/gems/puppet-3.7.3/lib/hiera/scope.rb
puppet-3.8.7 lib/hiera/scope.rb
puppet-3.8.7-x86-mingw32 lib/hiera/scope.rb
puppet-3.8.7-x64-mingw32 lib/hiera/scope.rb
puppet-3.8.6 lib/hiera/scope.rb
puppet-3.8.6-x86-mingw32 lib/hiera/scope.rb
puppet-retrospec-0.12.1 vendor/gems/puppet-3.7.3/lib/hiera/scope.rb
puppet-3.8.6-x64-mingw32 lib/hiera/scope.rb
puppet-retrospec-0.12.0 vendor/gems/puppet-3.7.3/lib/hiera/scope.rb
puppet-3.8.5 lib/hiera/scope.rb
puppet-3.8.5-x86-mingw32 lib/hiera/scope.rb
puppet-3.8.5-x64-mingw32 lib/hiera/scope.rb
puppet-3.8.4 lib/hiera/scope.rb
puppet-3.8.4-x86-mingw32 lib/hiera/scope.rb
puppet-3.8.4-x64-mingw32 lib/hiera/scope.rb
puppet-retrospec-0.11.0 vendor/gems/puppet-3.7.3/lib/hiera/scope.rb
puppet-retrospec-0.10.0 vendor/gems/puppet-3.7.3/lib/hiera/scope.rb
puppet-retrospec-0.9.1 vendor/gems/puppet-3.7.3/lib/hiera/scope.rb
puppet-retrospec-0.9.0 vendor/gems/puppet-3.7.3/lib/hiera/scope.rb
puppet-retrospec-0.8.1 vendor/gems/puppet-3.7.3/lib/hiera/scope.rb