Re: [patch] Use hash for optional args with long argument list in Ruby bindings
From: Joe Swatosh <joe.swatosh_at_gmail.com>
Date: 2007-11-15 19:52:51 CET
Hi kou,
On Nov 15, 2007 4:29 AM, Kouhei Sutou <kou@cozmixng.org> wrote:
Now that I understand you were suggesting "required options" I'd like to
-- Joe Index: src-trunk/subversion/bindings/swig/ruby/svn/wc.rb =================================================================== --- src-trunk/subversion/bindings/swig/ruby/svn/wc.rb (revision 27830) +++ src-trunk/subversion/bindings/swig/ruby/svn/wc.rb (working copy) @@ -307,47 +307,45 @@ editor end - REQUIRED_UPDATE_EDITOR_KEYS = [:target_revision, :target] - OPTIONAL_UPDATE_EDITOR_KEYS = [:use_commit_times, :depth, - :allow_unver_obstruction, :diff3_cmd, - :notify_func, :cancel_func, - :traversal_info, :preserved_exts] - def update_editor2(options={}) - default_options = { + UPDATE_EDITOR2_REQUIRED_ARGUMENTS_KEYS = [:target_revision, :target] + UPDATE_EDITOR2_OPTIONAL_ARGUMENTS_DEFAULTS = { :use_commit_times => true, :depth => nil, :allow_unver_obstruction => false, :diff3_cmd => nil, :notify_func => nil, :cancel_func => nil, - :traversal_info => _traversal_info, + :traversal_info => nil, # for now, really self._traversal_info() :preserved_exts => [] } - options = default_options.merge(options) - Util.validate_options(options, - OPTIONAL_UPDATE_EDITOR_KEYS, - REQUIRED_UPDATE_EDITOR_KEYS) + def update_editor2(arguments={}) + arguments = UPDATE_EDITOR2_OPTIONAL_ARGUMENTS_DEFAULTS. + merge(:traversal_info => _traversal_info). + merge(arguments) + Util.validate_options(arguments, + UPDATE_EDITOR2_OPTIONAL_ARGUMENTS_DEFAULTS.keys, + UPDATE_EDITOR2_REQUIRED_ARGUMENTS_KEYS) # TODO(rb support fetch_fun): implement support for the fetch_func # callback. - options[:fetch_func] = nil + arguments[:fetch_func] = nil # TODO(rb support conflict_fun): implement support for the # conflict_func callback. - options[:conflict_func] = nil + arguments[:conflict_func] = nil - results = Wc.get_update_editor3(options[:target_revision], self, - options[:target], - options[:use_commit_times], - options[:depth], - options[:allow_unver_obstruction], - options[:notify_func], - options[:cancel_func], - options[:conflict_func], - options[:fetch_func], - options[:diff3_cmd], - options[:preserved_exts], - options[:traversal_info]) + results = Wc.get_update_editor3(arguments[:target_revision], self, + arguments[:target], + arguments[:use_commit_times], + arguments[:depth], + arguments[:allow_unver_obstruction], + arguments[:notify_func], + arguments[:cancel_func], + arguments[:conflict_func], + arguments[:fetch_func], + arguments[:diff3_cmd], + arguments[:preserved_exts], + arguments[:traversal_info]) target_revision_address, editor, editor_baton = results editor.__send__(:target_revision_address=, target_revision_address) editor.baton = editor_baton
---------------------------------------------------------------------
|
This is an archived mail posted to the Subversion Dev mailing list.
This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.