Sha256: 84c1e043dea34cc7ffec54ac9ab9cb099387c1c9289d31e59b16713db5699f4b

Contents?: true

Size: 939 Bytes

Versions: 107

Compression:

Stored size: 939 Bytes

Contents

# Where we store helper methods related to, um, methods.
module Puppet::Util::MethodHelper
  def requiredopts(*names)
    names.each do |name|
      devfail("#{name} is a required option for #{self.class}") if self.send(name).nil?
    end
  end

  # Iterate over a hash, treating each member as an attribute.
  def set_options(options)
    options.each do |param,value|
      method = param.to_s + "="
      if respond_to? method
        self.send(method, value)
      else
        raise ArgumentError, _("Invalid parameter %{parameter} to object class %{class_name}") % { parameter: param, class_name: self.class }
      end
    end
  end

  # Take a hash and convert all of the keys to symbols if possible.
  def symbolize_options(options)
    options.inject({}) do |hash, opts|
      if opts[0].respond_to? :intern
        hash[opts[0].intern] = opts[1]
      else
        hash[opts[0]] = opts[1]
      end
      hash
    end
  end
end

Version data entries

107 entries across 107 versions & 2 rubygems

Version Path
puppet-5.5.22 lib/puppet/util/methodhelper.rb
puppet-5.5.22-x86-mingw32 lib/puppet/util/methodhelper.rb
puppet-5.5.22-x64-mingw32 lib/puppet/util/methodhelper.rb
puppet-5.5.22-universal-darwin lib/puppet/util/methodhelper.rb
puppet-5.5.21 lib/puppet/util/methodhelper.rb
puppet-5.5.21-x86-mingw32 lib/puppet/util/methodhelper.rb
puppet-5.5.21-x64-mingw32 lib/puppet/util/methodhelper.rb
puppet-5.5.21-universal-darwin lib/puppet/util/methodhelper.rb
puppet-5.5.20 lib/puppet/util/methodhelper.rb
puppet-5.5.20-x86-mingw32 lib/puppet/util/methodhelper.rb
puppet-5.5.20-x64-mingw32 lib/puppet/util/methodhelper.rb
puppet-5.5.20-universal-darwin lib/puppet/util/methodhelper.rb
puppet-5.5.19 lib/puppet/util/methodhelper.rb
puppet-5.5.19-x86-mingw32 lib/puppet/util/methodhelper.rb
puppet-5.5.19-x64-mingw32 lib/puppet/util/methodhelper.rb
puppet-5.5.19-universal-darwin lib/puppet/util/methodhelper.rb
puppet-5.5.18 lib/puppet/util/methodhelper.rb
puppet-5.5.18-x86-mingw32 lib/puppet/util/methodhelper.rb
puppet-5.5.18-x64-mingw32 lib/puppet/util/methodhelper.rb
puppet-5.5.18-universal-darwin lib/puppet/util/methodhelper.rb