Fix keyword warnings
This commit is contained in:
parent
cb479c9d5e
commit
4e7cefb857
|
@ -337,10 +337,10 @@ module Dry
|
|||
# @api public
|
||||
def self.expose(*names, **options, &block)
|
||||
if names.length == 1
|
||||
exposures.add(names.first, block, options)
|
||||
exposures.add(names.first, block, **options)
|
||||
else
|
||||
names.each do |name|
|
||||
exposures.add(name, options)
|
||||
exposures.add(name, **options)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -26,7 +26,7 @@ module Dry
|
|||
end
|
||||
|
||||
def bind(obj)
|
||||
self.class.new(name, proc, obj, options)
|
||||
self.class.new(name, proc, obj, **options)
|
||||
end
|
||||
|
||||
def dependency_names
|
||||
|
@ -76,23 +76,31 @@ module Dry
|
|||
private
|
||||
|
||||
def call_proc(input, locals)
|
||||
args = proc_args(input, locals)
|
||||
args, keywords = proc_args(input, locals)
|
||||
|
||||
if proc.is_a?(Method)
|
||||
proc.(*args)
|
||||
if keywords.empty?
|
||||
if proc.is_a?(Method)
|
||||
proc.(*args)
|
||||
else
|
||||
object.instance_exec(*args, &proc)
|
||||
end
|
||||
else
|
||||
object.instance_exec(*args, &proc)
|
||||
if proc.is_a?(Method)
|
||||
proc.(*args, **keywords)
|
||||
else
|
||||
object.instance_exec(*args, **keywords, &proc)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def proc_args(input, locals)
|
||||
dependency_args = proc_dependency_args(locals)
|
||||
input_args = proc_input_args(input)
|
||||
keywords = proc_input_args(input)
|
||||
|
||||
if input_args.any?
|
||||
dependency_args << input_args
|
||||
if keywords.empty?
|
||||
[dependency_args, {}]
|
||||
else
|
||||
dependency_args
|
||||
[dependency_args, keywords]
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ module Dry
|
|||
end
|
||||
|
||||
def add(name, proc = nil, **options)
|
||||
exposures[name] = Exposure.new(name, proc, options)
|
||||
exposures[name] = Exposure.new(name, proc, **options)
|
||||
end
|
||||
|
||||
def import(name, exposure)
|
||||
|
|
|
@ -207,6 +207,7 @@ module Dry
|
|||
super
|
||||
end
|
||||
end
|
||||
ruby2_keywords(:method_missing) if respond_to?(:ruby2_keywords, true)
|
||||
|
||||
def respond_to_missing?(name, include_private = false)
|
||||
CONVENIENCE_METHODS.include?(name) || _value.respond_to?(name, include_private) || super
|
||||
|
|
|
@ -96,7 +96,7 @@ module Dry
|
|||
partial_name = _inflector.underscore(_inflector.demodulize(partial_name.to_s))
|
||||
end
|
||||
|
||||
_render_env.partial(partial_name, _render_scope(locals), &block)
|
||||
_render_env.partial(partial_name, _render_scope(**locals), &block)
|
||||
end
|
||||
|
||||
# Build a new scope using a scope class matching the provided name
|
||||
|
@ -160,6 +160,7 @@ module Dry
|
|||
super
|
||||
end
|
||||
end
|
||||
ruby2_keywords(:method_missing) if respond_to?(:ruby2_keywords, true)
|
||||
|
||||
def respond_to_missing?(name, include_private = false)
|
||||
_locals.key?(name) ||
|
||||
|
|
|
@ -330,12 +330,12 @@ RSpec.describe "exposures" do
|
|||
|
||||
input = {users: users, context: context}
|
||||
|
||||
expect(view.(input).to_s).to eql(
|
||||
expect(view.(**input).to_s).to eql(
|
||||
'<!DOCTYPE html><html><head><title>dry-view rocks!</title></head><body><ul><li>Jane (jane@doe.org)</li><li>Joe (joe@doe.org)</li></ul><div class="count">COUNT: 2 users</div></body></html>'
|
||||
)
|
||||
|
||||
expect(view.(input).locals).to include(:users, :users_count)
|
||||
expect(view.(input).locals).not_to include(:prefix)
|
||||
expect(view.(**input).locals).to include(:users, :users_count)
|
||||
expect(view.(**input).locals).not_to include(:prefix)
|
||||
end
|
||||
|
||||
it "inherit exposures from parent class" do
|
||||
|
@ -369,12 +369,12 @@ RSpec.describe "exposures" do
|
|||
|
||||
input = {users: users, context: context}
|
||||
|
||||
expect(child.(input).to_s).to eql(
|
||||
expect(child.(**input).to_s).to eql(
|
||||
'<!DOCTYPE html><html><head><title>dry-view rocks!</title></head><body><ul><li>Jane (jane@doe.org)</li><li>Joe (joe@doe.org)</li></ul><div class="count">COUNT: 2 users</div><div class="inherit">Child expose</div></body></html>'
|
||||
)
|
||||
|
||||
expect(child.(input).locals).to include(:users, :users_count, :child_expose)
|
||||
expect(child.(input).locals).not_to include(:prefix)
|
||||
expect(child.(**input).locals).to include(:users, :users_count, :child_expose)
|
||||
expect(child.(**input).locals).not_to include(:prefix)
|
||||
end
|
||||
|
||||
it "inherit exposures from parent class and allow to override them" do
|
||||
|
@ -412,12 +412,12 @@ RSpec.describe "exposures" do
|
|||
|
||||
input = {users: users, context: context}
|
||||
|
||||
expect(child.(input).to_s).to eql(
|
||||
expect(child.(**input).to_s).to eql(
|
||||
'<!DOCTYPE html><html><head><title>dry-view rocks!</title></head><body><ul><li>Jane (jane@doe.org)</li><li>Joe (joe@doe.org)</li></ul><div class="count">COUNT: 2 users overrided</div><div class="inherit">Child expose</div></body></html>'
|
||||
)
|
||||
|
||||
expect(child.(input).locals).to include(:users, :users_count, :child_expose)
|
||||
expect(child.(input).locals).not_to include(:prefix)
|
||||
expect(child.(**input).locals).to include(:users, :users_count, :child_expose)
|
||||
expect(child.(**input).locals).not_to include(:prefix)
|
||||
end
|
||||
|
||||
it "makes exposures available to layout" do
|
||||
|
|
Loading…
Reference in New Issue