Skip to content

Commit 633dcdf

Browse files
committed
Remove all ruby2_keywords
It only affected the auto_curry plugin in a minor way
1 parent 5098588 commit 633dcdf

22 files changed

+41
-57
lines changed

Gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ group :sql do
3434
# else
3535
# gem 'rom-sql', '~> 3.0'
3636
# end
37-
gem 'rom-sql', github: 'rom-rb/rom-sql', branch: 'release-3.6'
37+
gem 'rom-sql', github: 'rom-rb/rom-sql', branch: 'release-3.7'
3838
end
3939

4040
group :test do

changeset/lib/rom/changeset/stateful.rb

+2-3
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,9 @@ def respond_to_missing?(meth, include_private = false)
266266
end
267267

268268
# @api private
269-
def method_missing(meth, *args, &block)
269+
def method_missing(meth, *args, **kwargs, &block)
270270
if __data__.respond_to?(meth)
271-
response = __data__.__send__(meth, *args, &block)
271+
response = __data__.__send__(meth, *args, **kwargs, &block)
272272

273273
if response.is_a?(__data__.class)
274274
with(__data__: response)
@@ -279,7 +279,6 @@ def method_missing(meth, *args, &block)
279279
super
280280
end
281281
end
282-
ruby2_keywords(:method_missing) if respond_to?(:ruby2_keywords, true)
283282
end
284283
end
285284
end

changeset/spec/unit/map_spec.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,10 @@ def extend_data(tuple)
8282
{ **t, three: t.fetch(:three) { next_value } }
8383
end
8484

85-
def initialize(*)
85+
def initialize(...)
8686
super
8787
@counter = 0
8888
end
89-
ruby2_keywords(:initialize) if respond_to?(:ruby2_keywords, true)
9089

9190
def default_command_type
9291
:test

core/lib/rom/association_set.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@ module ROM
99
# @api public
1010
class AssociationSet < ROM::Registry
1111
# @api private
12-
def initialize(*)
12+
def initialize(...)
1313
super
1414
elements.values.each do |assoc|
1515
elements[assoc.name] = assoc if assoc.aliased? && !key?(assoc.name)
1616
end
1717
end
18-
ruby2_keywords(:initialize) if respond_to?(:ruby2_keywords, true)
1918
end
2019
end

core/lib/rom/associations/many_to_many.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@ class ManyToMany < Abstract
1414
attr_reader :join_relation
1515

1616
# @api private
17-
def initialize(*)
17+
def initialize(*, **)
1818
super
1919
@join_relation = relations[through]
2020
end
21-
ruby2_keywords(:initialize) if respond_to?(:ruby2_keywords, true)
2221

2322
# Adapters should implement this method
2423
#

core/lib/rom/attribute.rb

+2-3
Original file line numberDiff line numberDiff line change
@@ -405,9 +405,9 @@ def meta_options_ast
405405
private
406406

407407
# @api private
408-
def method_missing(meth, *args, &block)
408+
def method_missing(meth, *args, **kwargs, &block)
409409
if type.respond_to?(meth)
410-
response = type.__send__(meth, *args, &block)
410+
response = type.__send__(meth, *args, **kwargs, &block)
411411

412412
if response.is_a?(type.class)
413413
self.class.new(response, **options)
@@ -418,6 +418,5 @@ def method_missing(meth, *args, &block)
418418
super
419419
end
420420
end
421-
ruby2_keywords(:method_missing) if respond_to?(:ruby2_keywords, true)
422421
end
423422
end

core/lib/rom/auto_curry.rb

+11-5
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,20 @@ def auto_curry(name, &block)
4242

4343
return unless public_instance_methods.include?(name) && arity != 0
4444

45-
mod = Module.new
45+
mod = ::Module.new
4646

4747
mod.module_eval do
48-
define_method(name) do |*args, &mblock|
48+
define_method(name) do |*args, **kwargs, &mblock|
49+
kwargs_size =
50+
if kwargs.empty?
51+
0
52+
else
53+
1
54+
end
55+
4956
response =
50-
if arity < 0 || arity == args.size
51-
super(*args, &mblock)
57+
if arity < 0 || arity == (args.size + kwargs_size)
58+
super(*args, **kwargs, &mblock)
5259
else
5360
self.class.curried.new(self, view: name, curry_args: args, arity: arity)
5461
end
@@ -59,7 +66,6 @@ def auto_curry(name, &block)
5966
response
6067
end
6168
end
62-
ruby2_keywords(name) if respond_to?(:ruby2_keywords, true)
6369
end
6470

6571
auto_curried_methods << name

core/lib/rom/commands/class_interface.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,8 @@ def relation_methods_mod(relation_class)
253253
Module.new do
254254
relation_class.view_methods.each do |meth|
255255
module_eval <<-RUBY, __FILE__, __LINE__ + 1
256-
def #{meth}(*args)
257-
response = relation.public_send(:#{meth}, *args)
256+
def #{meth}(*args, **kwargs)
257+
response = relation.public_send(:#{meth}, *args, **kwargs)
258258
259259
if response.is_a?(relation.class)
260260
new(response)

core/lib/rom/commands/lazy.rb

+2-3
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ def respond_to_missing?(name, include_private = false)
8383
private
8484

8585
# @api private
86-
def method_missing(name, *args, &block)
86+
def method_missing(name, *args, **kwargs, &block)
8787
if command.respond_to?(name)
88-
response = command.public_send(name, *args, &block)
88+
response = command.public_send(name, *args, **kwargs, &block)
8989

9090
if response.instance_of?(command.class)
9191
self.class.new(response, evaluator, command_proc)
@@ -96,7 +96,6 @@ def method_missing(name, *args, &block)
9696
super
9797
end
9898
end
99-
ruby2_keywords(:method_missing) if respond_to?(:ruby2_keywords, true)
10099
end
101100
end
102101
end

core/lib/rom/gateway.rb

+2-6
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class Gateway
7878
# @return [Gateway] a specific gateway subclass
7979
#
8080
# @api public
81-
def self.setup(gateway_or_scheme, *args)
81+
def self.setup(gateway_or_scheme, *args, **kwargs)
8282
case gateway_or_scheme
8383
when String
8484
raise ArgumentError, <<-STRING.gsub(/^ {10}/, '')
@@ -91,7 +91,7 @@ def self.setup(gateway_or_scheme, *args)
9191
if klass.instance_method(:initialize).arity.zero?
9292
klass.new
9393
else
94-
klass.new(*args)
94+
klass.new(*args, **kwargs)
9595
end
9696
else
9797
raise ArgumentError, "Can't accept arguments when passing an instance" unless args.empty?
@@ -100,10 +100,6 @@ def self.setup(gateway_or_scheme, *args)
100100
end
101101
end
102102

103-
class << self
104-
ruby2_keywords(:setup) if respond_to?(:ruby2_keywords, true)
105-
end
106-
107103
# Get gateway subclass for a specific adapter
108104
#
109105
# @param [Symbol] type Adapter identifier

core/lib/rom/header/attribute.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class Embedded < Attribute
113113
attr_reader :header
114114

115115
# @api private
116-
def initialize(*)
116+
def initialize(*, **)
117117
super
118118
@header = meta.fetch(:header)
119119
end

core/lib/rom/initializer.rb

+2-4
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,16 @@ module Initializer
88
# @api private
99
module DefineWithHook
1010
# @api private
11-
def param(*)
11+
def param(*, **)
1212
super.tap { __define_with__ }
1313
end
14-
ruby2_keywords(:param) if respond_to?(:ruby2_keywords, true)
1514

1615
# @api private
17-
def option(*)
16+
def option(*, **)
1817
super.tap do
1918
__define_with__ unless method_defined?(:with)
2019
end
2120
end
22-
ruby2_keywords(:option) if respond_to?(:ruby2_keywords, true)
2321

2422
# @api private
2523
def __define_with__

core/lib/rom/mapper/dsl.rb

+2-3
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,13 @@ def dsl
105105
# Delegate Attribute DSL method to the dsl instance
106106
#
107107
# @api private
108-
def method_missing(name, *args, &block)
108+
def method_missing(name, *args, **kwargs, &block)
109109
if dsl.respond_to?(name)
110-
dsl.public_send(name, *args, &block)
110+
dsl.public_send(name, *args, **kwargs, &block)
111111
else
112112
super
113113
end
114114
end
115-
ruby2_keywords(:method_missing) if respond_to?(:ruby2_keywords, true)
116115
end
117116
end
118117
end

core/lib/rom/mapper_compiler.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,12 @@ class MapperCompiler
2323

2424
attr_reader :mapper_options
2525

26-
def initialize(*)
26+
def initialize(*, **)
2727
super
2828
@struct_compiler = StructCompiler.new(cache: cache)
2929
@cache = cache.namespaced(:mappers)
3030
@mapper_options = self.class.mapper_options
3131
end
32-
ruby2_keywords(:initialize) if respond_to?(:ruby2_keywords, true)
3332

3433
def call(ast)
3534
cache.fetch_or_store(ast.hash) { Mapper.build(Header.coerce(*visit(ast))) }

core/lib/rom/pipeline.rb

+2-3
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ def decorate?(response)
6262
end
6363

6464
# @api private
65-
def method_missing(name, *args, &block)
65+
def method_missing(name, *args, **kwargs, &block)
6666
if left.respond_to?(name)
67-
response = left.__send__(name, *args, &block)
67+
response = left.__send__(name, *args, **kwargs, &block)
6868

6969
if decorate?(response)
7070
self.class.new(response, right)
@@ -75,7 +75,6 @@ def method_missing(name, *args, &block)
7575
super
7676
end
7777
end
78-
ruby2_keywords(:method_missing) if respond_to?(:ruby2_keywords, true)
7978
end
8079

8180
# Base composite class with left-to-right pipeline behavior

core/lib/rom/relation/curried.rb

+2-3
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ def composite_class
105105
end
106106

107107
# @api private
108-
def method_missing(meth, *args, &block)
108+
def method_missing(meth, *args, **kwargs, &block)
109109
if relation.respond_to?(meth)
110-
response = relation.__send__(meth, *args, &block)
110+
response = relation.__send__(meth, *args, **kwargs, &block)
111111

112112
super if response.is_a?(self.class)
113113

@@ -120,7 +120,6 @@ def method_missing(meth, *args, &block)
120120
super
121121
end
122122
end
123-
ruby2_keywords(:method_missing) if respond_to?(:ruby2_keywords, true)
124123
end
125124
end
126125
end

core/lib/rom/schema.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,11 @@ def self.attributes(attributes, attr_class)
160160
end
161161

162162
# @api private
163-
def initialize(*)
163+
def initialize(*, **)
164164
super
165165

166166
yield(self) if block_given?
167167
end
168-
ruby2_keywords(:initialize) if respond_to?(:ruby2_keywords, true)
169168

170169
# Abstract method for creating a new relation based on schema definition
171170
#

core/lib/rom/schema/dsl.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,14 @@ class DSL < BasicObject
5555
attr_reader :associations_dsl
5656

5757
# @api private
58-
def initialize(*, &block)
58+
def initialize(*, **, &block)
5959
super
6060

6161
@attributes = {}
6262
@plugins = {}
6363

6464
@definition = block
6565
end
66-
ruby2_keywords(:initialize) if respond_to?(:ruby2_keywords, true)
6766

6867
# Defines a relation attribute with its type and options.
6968
#

core/lib/rom/struct_compiler.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@ class StructCompiler < Dry::Types::Compiler
1818
option :cache, default: -> { Cache.new }
1919

2020
# @api private
21-
def initialize(*)
21+
def initialize(*, **)
2222
super
2323
@cache = cache.namespaced(:structs)
2424
end
25-
ruby2_keywords(:initialize) if respond_to?(:ruby2_keywords, true)
2625

2726
# Build a struct class based on relation header ast
2827
#

core/lib/rom/support/memoizable.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@ def memoize(*names)
1111
prepend(Memoizer.new(self, names))
1212
end
1313

14-
def new(*)
14+
def new(*, **, &)
1515
obj = super
1616
obj.instance_variable_set(:'@__memoized__', MEMOIZED_HASH.dup)
1717
obj
1818
end
19-
ruby2_keywords(:new) if respond_to?(:ruby2_keywords, true)
2019
end
2120

2221
def self.included(klass)

repository/lib/rom/repository.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,10 @@ class Repository
104104
# Initializes a new repository object
105105
#
106106
# @api private
107-
def initialize(*)
107+
def initialize(*, **)
108108
super
109109
@relations = {}
110110
end
111-
ruby2_keywords(:initialize) if respond_to?(:ruby2_keywords, true)
112111

113112
# Open a database transaction
114113
#

repository/lib/rom/repository/root.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,10 @@ def self.inherited(klass)
5656
end
5757

5858
# @see Repository#initialize
59-
def initialize(*)
59+
def initialize(*, **)
6060
super
6161
@root = set_relation(self.class.root)
6262
end
63-
ruby2_keywords(:initialize) if respond_to?(:ruby2_keywords, true)
6463
end
6564
end
6665
end

0 commit comments

Comments
 (0)