Skip to content

Commit

Permalink
Target 3.1+ syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
flash-gordon committed Jan 1, 2025
1 parent 97421ad commit 2cf8dbe
Show file tree
Hide file tree
Showing 13 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This is a config synced from dry-rb/template-gem repo

AllCops:
TargetRubyVersion: 3.0
TargetRubyVersion: 3.1
NewCops: disable
SuggestExtensions: false
Exclude:
Expand Down
8 changes: 4 additions & 4 deletions lib/dry/initializer/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,11 @@ def initialize(extended_class = nil, null: UNDEFINED)
def add_definition(option, name, type, block, **opts)
opts = {
parent: extended_class,
option: option,
null: null,
option:,
null:,
source: name,
type: type,
block: block,
type:,
block:,
**opts
}

Expand Down
10 changes: 5 additions & 5 deletions lib/dry/initializer/definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ class Definition
def options
{
as: target,
type: type,
optional: optional,
default: default,
reader: reader,
desc: desc
type:,
optional:,
default:,
reader:,
desc:
}.compact
end

Expand Down
2 changes: 1 addition & 1 deletion lib/dry/initializer/dispatchers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def <<(dispatcher)
# @return [Hash<Symbol, Objct>] normalized set of options
#
def call(**options)
options = {null: null, **options}
options = {null:, **options}
pipeline.reduce(options) { |opts, dispatcher| dispatcher.call(**opts) }
end

Expand Down
2 changes: 1 addition & 1 deletion lib/dry/initializer/dispatchers/build_nested_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def call(parent:, source:, target:, type: nil, block: nil, **options)
check_certainty!(source, type, block)
check_name!(target, block)
type ||= build_nested_type(parent, target, block)
{parent: parent, source: source, target: target, type: type, **options}
{parent:, source:, target:, type:, **options}
end
# rubocop: enable Metrics/ParameterLists

Expand Down
2 changes: 1 addition & 1 deletion lib/dry/initializer/dispatchers/check_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def call(source:, type: nil, wrap: 0, **options)
check_if_callable! source, type
check_arity! source, type, wrap

{source: source, type: type, wrap: wrap, **options}
{source:, type:, wrap:, **options}
end

private
Expand Down
2 changes: 1 addition & 1 deletion lib/dry/initializer/dispatchers/prepare_default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def call(default: nil, optional: nil, **options)
default = callable! default
check_arity! default

{default: default, optional: (optional | default), **options}
{default:, optional: (optional | default), **options}
end

private
Expand Down
2 changes: 1 addition & 1 deletion lib/dry/initializer/dispatchers/prepare_ivar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module PrepareIvar
def call(target:, **options)
ivar = "@#{target}".delete("?").to_sym

{target: target, ivar: ivar, **options}
{target:, ivar:, **options}
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/dry/initializer/dispatchers/prepare_optional.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def call(optional: nil, default: nil, required: nil, **options)
optional ||= default
optional &&= !required

{optional: !!optional, default: default, **options}
{optional: !!optional, default:, **options}
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/dry/initializer/dispatchers/prepare_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def call(target: nil, reader: :public, **options)
else invalid_reader!(target, reader)
end

{target: target, reader: reader, **options}
{target:, reader:, **options}
end

private
Expand Down
2 changes: 1 addition & 1 deletion lib/dry/initializer/dispatchers/prepare_target.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def call(source:, target: nil, as: nil, **options)
check_ruby_name!(target)
check_reserved_names!(target)

{source: source, target: target, **options}
{source:, target:, **options}
end

private
Expand Down
2 changes: 1 addition & 1 deletion lib/dry/initializer/dispatchers/unwrap_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module UnwrapType
def call(type: nil, wrap: 0, **options)
type, count = unwrap(type, wrap)

{type: type, wrap: count, **options}
{type:, wrap: count, **options}
end

private
Expand Down
4 changes: 2 additions & 2 deletions lib/dry/initializer/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def [](undefined: true, **)
# @return [Module]
# @yield proc defining params and options
def define(procedure = nil, &block)
config = Config.new(null: null)
config = Config.new(null:)
config.instance_exec(&procedure || block)
config.mixin.include Mixin::Root
config.mixin
Expand All @@ -34,7 +34,7 @@ def define(procedure = nil, &block)
private

def extended(klass)
config = Config.new(klass, null: null)
config = Config.new(klass, null:)
klass.send :instance_variable_set, :@dry_initializer, config
klass.include Mixin::Root
end
Expand Down

0 comments on commit 2cf8dbe

Please sign in to comment.