aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/callbacks.rb
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2015-02-05 17:59:03 -0200
committerRafael Mendonça França <rafaelmfranca@gmail.com>2015-02-05 17:59:03 -0200
commit9cb461ba033c66a3bc91960e9274b804a7a42459 (patch)
treed68cb53c22618710425b17db26cf214e4029bf67 /activesupport/lib/active_support/callbacks.rb
parent459a9ea47fdcdb16dbcf6bd98e54a2fda5a16e39 (diff)
downloadrails-9cb461ba033c66a3bc91960e9274b804a7a42459.tar.gz
rails-9cb461ba033c66a3bc91960e9274b804a7a42459.tar.bz2
rails-9cb461ba033c66a3bc91960e9274b804a7a42459.zip
Use keyword arguments
Also remove the default value since it will be always passed and Array(nil) returns an empty array
Diffstat (limited to 'activesupport/lib/active_support/callbacks.rb')
-rw-r--r--activesupport/lib/active_support/callbacks.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/activesupport/lib/active_support/callbacks.rb b/activesupport/lib/active_support/callbacks.rb
index 98b8f0d34a..0d5035f637 100644
--- a/activesupport/lib/active_support/callbacks.rb
+++ b/activesupport/lib/active_support/callbacks.rb
@@ -373,14 +373,14 @@ module ActiveSupport
def filter; @key; end
def raw_filter; @filter; end
- def merge_conditional_options(chain, new_options)
+ def merge_conditional_options(chain, if_option:, unless_option:)
options = {
:if => @if.dup,
:unless => @unless.dup
}
- options[:if].concat Array(new_options.fetch(:unless, []))
- options[:unless].concat Array(new_options.fetch(:if, []))
+ options[:if].concat Array(unless_option)
+ options[:unless].concat Array(if_option)
self.class.build chain, @filter, @kind, options
end
@@ -701,7 +701,7 @@ module ActiveSupport
filter = chain.find {|c| c.matches?(type, filter) }
if filter && options.any?
- new_filter = filter.merge_conditional_options(chain, options)
+ new_filter = filter.merge_conditional_options(chain, if_option: options[:if], unless_option: options[:unless])
chain.insert(chain.index(filter), new_filter)
end