Issue #6759 has been updated by Daniel Pittman. Status changed from Needs Decision to Closed
It isn't that this is a bad plan, or isn't valuable, but it isn't anything of sufficient priority that we need an open ticket tracking it at this stage, for a purely internal bit of work. ---------------------------------------- Refactor #6759: Improve internal option handling pattern https://projects.puppetlabs.com/issues/6759 Author: Markus Roberts Status: Closed Priority: Normal Assignee: Daniel Pittman Category: plumbing Target version: Telly Affected Puppet version: Keywords: Branch: The code base contains many occurrences of the pattern: <pre> def initialize(..., options = {:op1 => 'default1'}) options.each { |opt, val| send(opt.to_s + "=", val) } : </pre> This is problematic for several reasons; it should be replaced with something like: <pre> def initialize(..., options = {}) options = { :opt1 => 'default', :opt2 => 'default2', : }.update options @opt1 = options.delete(:opt1) @opt2 = options.delete(:opt2) : raise "Unknown options: #{options.inspect}" unless options.empty? : </pre> If inheritance is an issue this can be augmented to: (in the base) <pre> def initialize(..., options = {}) parse_options({ :opt1 => 'default', :opt2 => 'default2', : }.update options) : def parse_options(options) @opt1 = options.delete(:opt1) @opt2 = options.delete(:opt2) : raise "Unknown options: #{options.inspect}" unless options.empty? : </pre> (in children) <pre> def initialize(..., options = {}) super(...,{ :opt3 => 'default3', :opt4 => 'default4', : }.update options) : def parse_options(options) @opt3 = options.delete(:opt3) @opt4 = options.delete(:opt4) : super(options) end </pre> -- You have received this notification because you have either subscribed to it, or are involved in it. To change your notification preferences, please click here: http://projects.puppetlabs.com/my/account -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/puppet-bugs?hl=en.
