Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArgumentError when proxying association method_missing under Ruby 3 due to improper kwarg handling #571

Closed
xeger opened this issue Jul 25, 2022 · 0 comments

Comments

@xeger
Copy link
Contributor

xeger commented Jul 25, 2022

I have a fix that handles SingleAssociation. I looked into fixing ManyAssociation too but I'm not sure it's warranted; Array doesn't make use of keyword args, so it would be awkward to test.

STR:

class Foo
  include Dynamoid::Document
  belongs_to :bar
end

class Bar
  include Dynamoid::Document

  def baz(kwarg1:, kwarg2:)
  end
end

# load a model
foo = ::Foo.find(foo_key, raise_error: false, consistent_read: true)

# follow a belongs_to association to a related model
bar = foo.bar

# call instance method of related model; will be proxied by Dynamoid::Associations::BelongsTo
bar.baz(kwarg1: 'hi')

Expected outcome: method is proxied faithfully to Bar#baz.

Actual outcome: keyword args are transformed into a hash that is passed as a positional arg

ArgumentError: wrong number of arguments (given 1, expected 0; required keywords: kwarg1, kwarg2)
xeger pushed a commit to xeger/dynamoid that referenced this issue Jul 25, 2022
andrykonchin added a commit that referenced this issue Jul 28, 2022
…g-rebase

Fix ruby3 method proxying rebase. Closes #571 (rebased on master)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant