mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #41703 from Shopify/tripple-dot
Use `...` argument forwarding instead of ruby2_keywords when possible
This commit is contained in:
commit
a8a1afd455
8 changed files with 37 additions and 50 deletions
|
@ -219,10 +219,9 @@ module ActionController
|
||||||
class << self
|
class << self
|
||||||
# Pushes the given Rack middleware and its arguments to the bottom of the
|
# Pushes the given Rack middleware and its arguments to the bottom of the
|
||||||
# middleware stack.
|
# middleware stack.
|
||||||
def use(*args, &block)
|
def use(...)
|
||||||
middleware_stack.use(*args, &block)
|
middleware_stack.use(...)
|
||||||
end
|
end
|
||||||
ruby2_keywords(:use) if respond_to?(:ruby2_keywords, true)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Alias for +middleware_stack+.
|
# Alias for +middleware_stack+.
|
||||||
|
|
|
@ -103,11 +103,10 @@ module ActionDispatch
|
||||||
include(*_url_for_modules) if respond_to?(:_url_for_modules)
|
include(*_url_for_modules) if respond_to?(:_url_for_modules)
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(*)
|
def initialize(...)
|
||||||
@_routes = nil
|
@_routes = nil
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
ruby2_keywords(:initialize) if respond_to?(:ruby2_keywords, true)
|
|
||||||
|
|
||||||
# Hook overridden in controller to add request information
|
# Hook overridden in controller to add request information
|
||||||
# with +default_url_options+. Application logic should not
|
# with +default_url_options+. Application logic should not
|
||||||
|
|
|
@ -7,14 +7,12 @@ module ActiveJob
|
||||||
@job_class = job_class
|
@job_class = job_class
|
||||||
end
|
end
|
||||||
|
|
||||||
def perform_now(*args)
|
def perform_now(...)
|
||||||
@job_class.new(*args).perform_now
|
@job_class.new(...).perform_now
|
||||||
end
|
end
|
||||||
ruby2_keywords(:perform_now) if respond_to?(:ruby2_keywords, true)
|
|
||||||
|
|
||||||
def perform_later(*args)
|
def perform_later(...)
|
||||||
@job_class.new(*args).enqueue @options
|
@job_class.new(...).enqueue @options
|
||||||
end
|
end
|
||||||
ruby2_keywords(:perform_later) if respond_to?(:ruby2_keywords, true)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -25,15 +25,14 @@ module ActiveJob
|
||||||
# Job#arguments or false if the enqueue did not succeed.
|
# Job#arguments or false if the enqueue did not succeed.
|
||||||
#
|
#
|
||||||
# After the attempted enqueue, the job will be yielded to an optional block.
|
# After the attempted enqueue, the job will be yielded to an optional block.
|
||||||
def perform_later(*args)
|
def perform_later(...)
|
||||||
job = job_or_instantiate(*args)
|
job = job_or_instantiate(...)
|
||||||
enqueue_result = job.enqueue
|
enqueue_result = job.enqueue
|
||||||
|
|
||||||
yield job if block_given?
|
yield job if block_given?
|
||||||
|
|
||||||
enqueue_result
|
enqueue_result
|
||||||
end
|
end
|
||||||
ruby2_keywords(:perform_later) if respond_to?(:ruby2_keywords, true)
|
|
||||||
|
|
||||||
private
|
private
|
||||||
def job_or_instantiate(*args) # :doc:
|
def job_or_instantiate(*args) # :doc:
|
||||||
|
|
|
@ -14,10 +14,9 @@ module ActiveJob
|
||||||
#
|
#
|
||||||
# MyJob.perform_now("mike")
|
# MyJob.perform_now("mike")
|
||||||
#
|
#
|
||||||
def perform_now(*args)
|
def perform_now(...)
|
||||||
job_or_instantiate(*args).perform_now
|
job_or_instantiate(...).perform_now
|
||||||
end
|
end
|
||||||
ruby2_keywords(:perform_now) if respond_to?(:ruby2_keywords, true)
|
|
||||||
|
|
||||||
def execute(job_data) #:nodoc:
|
def execute(job_data) #:nodoc:
|
||||||
ActiveJob::Callbacks.run_callbacks(:execute) do
|
ActiveJob::Callbacks.run_callbacks(:execute) do
|
||||||
|
|
|
@ -196,8 +196,7 @@ class Mysql2ActiveSchemaTest < ActiveRecord::Mysql2TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def method_missing(method_symbol, *arguments)
|
def method_missing(...)
|
||||||
ActiveRecord::Base.connection.public_send(method_symbol, *arguments)
|
ActiveRecord::Base.connection.public_send(...)
|
||||||
end
|
end
|
||||||
ruby2_keywords(:method_missing) if respond_to?(:ruby2_keywords, true)
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -106,8 +106,7 @@ class PostgresqlActiveSchemaTest < ActiveRecord::PostgreSQLTestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def method_missing(method_symbol, *arguments)
|
def method_missing(...)
|
||||||
ActiveRecord::Base.connection.public_send(method_symbol, *arguments)
|
ActiveRecord::Base.connection.public_send(...)
|
||||||
end
|
end
|
||||||
ruby2_keywords(:method_missing) if respond_to?(:ruby2_keywords, true)
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -49,46 +49,41 @@ module Rails
|
||||||
@delete_operations = delete_operations
|
@delete_operations = delete_operations
|
||||||
end
|
end
|
||||||
|
|
||||||
def insert_before(*args, &block)
|
def insert_before(...)
|
||||||
@operations << -> middleware { middleware.insert_before(*args, &block) }
|
@operations << -> middleware { middleware.insert_before(...) }
|
||||||
end
|
end
|
||||||
ruby2_keywords(:insert_before) if respond_to?(:ruby2_keywords, true)
|
|
||||||
|
|
||||||
alias :insert :insert_before
|
alias :insert :insert_before
|
||||||
|
|
||||||
def insert_after(*args, &block)
|
def insert_after(...)
|
||||||
@operations << -> middleware { middleware.insert_after(*args, &block) }
|
@operations << -> middleware { middleware.insert_after(...) }
|
||||||
end
|
|
||||||
ruby2_keywords(:insert_after) if respond_to?(:ruby2_keywords, true)
|
|
||||||
|
|
||||||
def swap(*args, &block)
|
|
||||||
@operations << -> middleware { middleware.swap(*args, &block) }
|
|
||||||
end
|
|
||||||
ruby2_keywords(:swap) if respond_to?(:ruby2_keywords, true)
|
|
||||||
|
|
||||||
def use(*args, &block)
|
|
||||||
@operations << -> middleware { middleware.use(*args, &block) }
|
|
||||||
end
|
|
||||||
ruby2_keywords(:use) if respond_to?(:ruby2_keywords, true)
|
|
||||||
|
|
||||||
def delete(*args, &block)
|
|
||||||
@delete_operations << -> middleware { middleware.delete(*args, &block) }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def move_before(*args, &block)
|
def swap(...)
|
||||||
@delete_operations << -> middleware { middleware.move_before(*args, &block) }
|
@operations << -> middleware { middleware.swap(...) }
|
||||||
|
end
|
||||||
|
|
||||||
|
def use(...)
|
||||||
|
@operations << -> middleware { middleware.use(...) }
|
||||||
|
end
|
||||||
|
|
||||||
|
def delete(...)
|
||||||
|
@delete_operations << -> middleware { middleware.delete(...) }
|
||||||
|
end
|
||||||
|
|
||||||
|
def move_before(...)
|
||||||
|
@delete_operations << -> middleware { middleware.move_before(...) }
|
||||||
end
|
end
|
||||||
|
|
||||||
alias :move :move_before
|
alias :move :move_before
|
||||||
|
|
||||||
def move_after(*args, &block)
|
def move_after(...)
|
||||||
@delete_operations << -> middleware { middleware.move_after(*args, &block) }
|
@delete_operations << -> middleware { middleware.move_after(...) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def unshift(*args, &block)
|
def unshift(...)
|
||||||
@operations << -> middleware { middleware.unshift(*args, &block) }
|
@operations << -> middleware { middleware.unshift(...) }
|
||||||
end
|
end
|
||||||
ruby2_keywords(:unshift) if respond_to?(:ruby2_keywords, true)
|
|
||||||
|
|
||||||
def merge_into(other) #:nodoc:
|
def merge_into(other) #:nodoc:
|
||||||
(@operations + @delete_operations).each do |operation|
|
(@operations + @delete_operations).each do |operation|
|
||||||
|
|
Loading…
Reference in a new issue