Skip to content

Commit

Permalink
Drop variables and qualify constants
Browse files Browse the repository at this point in the history
Also remove one leftover from 2.7 ruby
  • Loading branch information
flash-gordon committed Jan 21, 2025
1 parent da0bb33 commit d2de00f
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 25 deletions.
6 changes: 5 additions & 1 deletion core/lib/rom/attribute.rb
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,11 @@ def to_write_type = type
# @api public
def optional
sum = self.class.new(super, **options)
read? ? sum.meta(read: meta[:read].optional) : sum
if read?
sum.meta(read: meta[:read].optional)
else
sum
end
end

# @api private
Expand Down
9 changes: 7 additions & 2 deletions core/lib/rom/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def gateway
# @api private
def execute(*)
raise(
NotImplementedError,
::NotImplementedError,
"#{self.class}##{__method__} must be implemented"
)
end
Expand All @@ -277,7 +277,12 @@ def call(*args, &)
apply_hooks(before_hooks, *args)
end

result = prepared ? execute(prepared, &) : execute(&)
result =
if prepared
execute(prepared, &)
else
execute(&)
end

if curried?
if !args.empty?
Expand Down
4 changes: 2 additions & 2 deletions core/lib/rom/command_compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def call(*args)
# @api private
def type
@_type ||= Commands.const_get(Inflector.classify(id))[adapter]
rescue NameError
rescue ::NameError
nil
end

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

# @api private
def visit_attribute(*_args) = nil
def visit_attribute(*) = nil

# Build a command object for a specific relation
#
Expand Down
4 changes: 2 additions & 2 deletions core/lib/rom/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Configuration
# @return [Configuration]
#
# @api private
def initialize(*args, &)
def initialize(*args)
@environment = Environment.new(*args)
@notifications = Notifications.event_bus(:configuration)
@setup = Setup.new(notifications)
Expand All @@ -66,7 +66,7 @@ def initialize(*args, &)
# @return [Configuration]
#
# @api public
def use(plugin, options = {})
def use(plugin, options = EMPTY_HASH)
if plugin.is_a?(::Array)
plugin.each { |p| use(p) }
elsif plugin.is_a?(::Hash)
Expand Down
2 changes: 1 addition & 1 deletion core/lib/rom/data_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def self.included(klass)
klass.class_eval do
extend ClassMethods

include Dry::Equalizer(:data)
include ::Dry::Equalizer(:data)

option :row_proc, default: -> { self.class.row_proc }
end
Expand Down
2 changes: 1 addition & 1 deletion core/lib/rom/enumerable_dataset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module EnumerableDataset
#
# @api private
def self.included(klass)
return unless klass.is_a?(Class)
return unless klass.is_a?(::Class)

klass.class_eval do
extend Initializer
Expand Down
10 changes: 7 additions & 3 deletions core/lib/rom/environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def initialize(*args)

# @api private
def configure_gateways(*args)
normalized_gateway_args = normalize_gateway_args(*args)
normalized_gateway_args = normalize_gateway_args(args)
normalized_gateways = normalize_gateways(normalized_gateway_args)

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

# @api private
def normalize_gateway_args(*args)
args.first.is_a?(Hash) ? args.first : { default: args }
def normalize_gateway_args(args)
if args.first.is_a?(::Hash)
args.first
else
{ default: args }
end
end

# Build gateways using the setup interface
Expand Down
2 changes: 1 addition & 1 deletion core/lib/rom/model_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def initialize(options = {})
if parts.any?
Inflector.constantize(parts.join('::'))
else
Object
::Object
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions core/lib/rom/open_struct.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ def initialize(attributes)

# @api private
def respond_to_missing?(meth, include_private = false)
super || instance_variables.include?(IVAR[meth])
instance_variable_defined?(IVAR[meth]) || super
end

private

# @api private
def method_missing(meth, *args, &)
def method_missing(meth, *, &)
ivar = IVAR[meth]

if instance_variables.include?(ivar)
if instance_variable_defined?(ivar)
instance_variable_get(ivar)
else
super
Expand Down
12 changes: 4 additions & 8 deletions core/lib/rom/registry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,14 @@ class Registry
option :cache, default: -> { Cache.new }

# @api private
def self.new(*args, **kwargs)
if args.empty? && kwargs.empty?
super({}, **{})
else
super
end
def self.new(elements = {}, *, **)
super
end

# Create a registry without options
#
# @api private
def self.build(elements = {}) = new(elements, **{})
def self.build(elements = {}) = new(elements)

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

# @api private
def fetch(key)
raise ArgumentError, 'key cannot be nil' if key.nil?
raise ::ArgumentError, 'key cannot be nil' if key.nil?

elements.fetch(key.to_sym) do
return yield if block_given?
Expand Down
2 changes: 1 addition & 1 deletion core/lib/rom/relation_registry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module ROM
# @api private
class RelationRegistry < Registry
# @api private
def initialize(elements = {}, **options)
def initialize(elements = {}, **)
super
yield(self, elements) if block_given?
end
Expand Down

0 comments on commit d2de00f

Please sign in to comment.