Sha256: 21448a655d7ceb6b91d78877488de05013f802b03193abebed9b536e7ede88fa

Contents?: true

Size: 1.35 KB

Versions: 134

Compression:

Stored size: 1.35 KB

Contents

module Puppet::Pops
module Binder
# The KeyFactory is responsible for creating keys used for lookup of bindings.
# @api public
#
class KeyFactory

  # @api public
  def binding_key(binding)
    named_key(binding.type, binding.name)
  end

  # @api public
  def named_key(type, name)
    [(Types::PDataType::DEFAULT.assignable?(type) ? Types::PDataType::DEFAULT : type), name]
  end

  # @api public
  def data_key(name)
    [Types::PDataType::DEFAULT, name]
  end

  # @api public
  def is_contributions_key?(s)
    return false unless s.is_a?(String)
    s.start_with?('mc_')
  end

  # @api public
  def multibind_contributions(multibind_id)
    "mc_#{multibind_id}"
  end

  # @api public
  def multibind_contribution_key_to_id(contributions_key)
    # removes the leading "mc_" from the key to get the multibind_id
    contributions_key[3..-1]
  end

  # @api public
  def is_named?(key)
    key.is_a?(Array) && key[1] && !key[1].empty?
  end

  # @api public
  def is_data?(key)
    return false unless key.is_a?(Array) && key[0].is_a?(Types::PAnyType)
    Types::PDataType::DEFAULT.assignable?(key[0])
  end

  # @api public
  def is_ruby?(key)
    key.is_a?(Array) && key[0].is_a?(Types::PRuntimeType) && key[0].runtime == :ruby
  end

  # Returns the type of the key
  # @api public
  #
  def get_type(key)
    return nil unless key.is_a?(Array)
    key[0]
  end
end
end
end

Version data entries

134 entries across 134 versions & 2 rubygems

Version Path
puppet-retrospec-1.8.0 vendor/pup410/lib/puppet/pops/binder/key_factory.rb
puppet-retrospec-1.7.0 vendor/pup410/lib/puppet/pops/binder/key_factory.rb
puppet-4.10.12 lib/puppet/pops/binder/key_factory.rb
puppet-4.10.12-x86-mingw32 lib/puppet/pops/binder/key_factory.rb
puppet-4.10.12-x64-mingw32 lib/puppet/pops/binder/key_factory.rb
puppet-4.10.12-universal-darwin lib/puppet/pops/binder/key_factory.rb
puppet-4.10.11 lib/puppet/pops/binder/key_factory.rb
puppet-4.10.11-x86-mingw32 lib/puppet/pops/binder/key_factory.rb
puppet-4.10.11-x64-mingw32 lib/puppet/pops/binder/key_factory.rb
puppet-4.10.11-universal-darwin lib/puppet/pops/binder/key_factory.rb
puppet-4.10.10 lib/puppet/pops/binder/key_factory.rb
puppet-4.10.10-x86-mingw32 lib/puppet/pops/binder/key_factory.rb
puppet-4.10.10-x64-mingw32 lib/puppet/pops/binder/key_factory.rb
puppet-4.10.10-universal-darwin lib/puppet/pops/binder/key_factory.rb
puppet-retrospec-1.6.1 vendor/pup410/lib/puppet/pops/binder/key_factory.rb
puppet-retrospec-1.6.0 vendor/pup410/lib/puppet/pops/binder/key_factory.rb
puppet-4.10.9 lib/puppet/pops/binder/key_factory.rb
puppet-4.10.9-x86-mingw32 lib/puppet/pops/binder/key_factory.rb
puppet-4.10.9-x64-mingw32 lib/puppet/pops/binder/key_factory.rb
puppet-4.10.9-universal-darwin lib/puppet/pops/binder/key_factory.rb