Skip to content

Commit d2de00f

Browse files
committed
Drop variables and qualify constants
Also remove one leftover from 2.7 ruby
1 parent da0bb33 commit d2de00f

11 files changed

+34
-25
lines changed

core/lib/rom/attribute.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,11 @@ def to_write_type = type
345345
# @api public
346346
def optional
347347
sum = self.class.new(super, **options)
348-
read? ? sum.meta(read: meta[:read].optional) : sum
348+
if read?
349+
sum.meta(read: meta[:read].optional)
350+
else
351+
sum
352+
end
349353
end
350354

351355
# @api private

core/lib/rom/command.rb

+7-2
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ def gateway
255255
# @api private
256256
def execute(*)
257257
raise(
258-
NotImplementedError,
258+
::NotImplementedError,
259259
"#{self.class}##{__method__} must be implemented"
260260
)
261261
end
@@ -277,7 +277,12 @@ def call(*args, &)
277277
apply_hooks(before_hooks, *args)
278278
end
279279

280-
result = prepared ? execute(prepared, &) : execute(&)
280+
result =
281+
if prepared
282+
execute(prepared, &)
283+
else
284+
execute(&)
285+
end
281286

282287
if curried?
283288
if !args.empty?

core/lib/rom/command_compiler.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def call(*args)
115115
# @api private
116116
def type
117117
@_type ||= Commands.const_get(Inflector.classify(id))[adapter]
118-
rescue NameError
118+
rescue ::NameError
119119
nil
120120
end
121121

@@ -172,7 +172,7 @@ def visit_relation(node, parent_relation = nil)
172172
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength, Metrics/PerceivedComplexity
173173

174174
# @api private
175-
def visit_attribute(*_args) = nil
175+
def visit_attribute(*) = nil
176176

177177
# Build a command object for a specific relation
178178
#

core/lib/rom/configuration.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class Configuration
5050
# @return [Configuration]
5151
#
5252
# @api private
53-
def initialize(*args, &)
53+
def initialize(*args)
5454
@environment = Environment.new(*args)
5555
@notifications = Notifications.event_bus(:configuration)
5656
@setup = Setup.new(notifications)
@@ -66,7 +66,7 @@ def initialize(*args, &)
6666
# @return [Configuration]
6767
#
6868
# @api public
69-
def use(plugin, options = {})
69+
def use(plugin, options = EMPTY_HASH)
7070
if plugin.is_a?(::Array)
7171
plugin.each { |p| use(p) }
7272
elsif plugin.is_a?(::Hash)

core/lib/rom/data_proxy.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def self.included(klass)
3333
klass.class_eval do
3434
extend ClassMethods
3535

36-
include Dry::Equalizer(:data)
36+
include ::Dry::Equalizer(:data)
3737

3838
option :row_proc, default: -> { self.class.row_proc }
3939
end

core/lib/rom/enumerable_dataset.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ module EnumerableDataset
4343
#
4444
# @api private
4545
def self.included(klass)
46-
return unless klass.is_a?(Class)
46+
return unless klass.is_a?(::Class)
4747

4848
klass.class_eval do
4949
extend Initializer

core/lib/rom/environment.rb

+7-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def initialize(*args)
2626

2727
# @api private
2828
def configure_gateways(*args)
29-
normalized_gateway_args = normalize_gateway_args(*args)
29+
normalized_gateway_args = normalize_gateway_args(args)
3030
normalized_gateways = normalize_gateways(normalized_gateway_args)
3131

3232
@gateways, @gateways_map = normalized_gateways.values_at(:gateways, :map)
@@ -38,8 +38,12 @@ def configure_gateways(*args)
3838
end
3939

4040
# @api private
41-
def normalize_gateway_args(*args)
42-
args.first.is_a?(Hash) ? args.first : { default: args }
41+
def normalize_gateway_args(args)
42+
if args.first.is_a?(::Hash)
43+
args.first
44+
else
45+
{ default: args }
46+
end
4347
end
4448

4549
# Build gateways using the setup interface

core/lib/rom/model_builder.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def initialize(options = {})
6060
if parts.any?
6161
Inflector.constantize(parts.join('::'))
6262
else
63-
Object
63+
::Object
6464
end
6565
end
6666
end

core/lib/rom/open_struct.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ def initialize(attributes)
1818

1919
# @api private
2020
def respond_to_missing?(meth, include_private = false)
21-
super || instance_variables.include?(IVAR[meth])
21+
instance_variable_defined?(IVAR[meth]) || super
2222
end
2323

2424
private
2525

2626
# @api private
27-
def method_missing(meth, *args, &)
27+
def method_missing(meth, *, &)
2828
ivar = IVAR[meth]
2929

30-
if instance_variables.include?(ivar)
30+
if instance_variable_defined?(ivar)
3131
instance_variable_get(ivar)
3232
else
3333
super

core/lib/rom/registry.rb

+4-8
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,14 @@ class Registry
2222
option :cache, default: -> { Cache.new }
2323

2424
# @api private
25-
def self.new(*args, **kwargs)
26-
if args.empty? && kwargs.empty?
27-
super({}, **{})
28-
else
29-
super
30-
end
25+
def self.new(elements = {}, *, **)
26+
super
3127
end
3228

3329
# Create a registry without options
3430
#
3531
# @api private
36-
def self.build(elements = {}) = new(elements, **{})
32+
def self.build(elements = {}) = new(elements)
3733

3834
# @api private
3935
def self.[](identifier)
@@ -78,7 +74,7 @@ def key?(name) = !name.nil? && elements.key?(name.to_sym)
7874

7975
# @api private
8076
def fetch(key)
81-
raise ArgumentError, 'key cannot be nil' if key.nil?
77+
raise ::ArgumentError, 'key cannot be nil' if key.nil?
8278

8379
elements.fetch(key.to_sym) do
8480
return yield if block_given?

core/lib/rom/relation_registry.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module ROM
66
# @api private
77
class RelationRegistry < Registry
88
# @api private
9-
def initialize(elements = {}, **options)
9+
def initialize(elements = {}, **)
1010
super
1111
yield(self, elements) if block_given?
1212
end

0 commit comments

Comments
 (0)