Module: Puppet::Util::NetworkDevice::ValueHelper
- Defined in:
- lib/puppet/util/network_device/value_helper.rb
Instance Method Summary collapse
Instance Method Details
#define_value_method(methods) ⇒ Object
2 3 4 5 6 7 8 9 10 11 |
# File 'lib/puppet/util/network_device/value_helper.rb', line 2 def define_value_method(methods) methods.each do |meth| define_method(meth) do |*args, &block| # return the current value if we are called like an accessor return instance_variable_get("@#{meth}".to_sym) if args.empty? && block.nil? # set the new value if there is any instance_variable_set("@#{meth}".to_sym, (block.nil? ? args.first : block)) end end end |