Expose with :if and lambda stopped working on Ruby 2.4.1
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
Research direction
Start at entity.rb:477 and inspect how exec_with_object invokes the :if lambda under Ruby 2.4.1, comparing it with Ruby 2.4.0 using the minimal expose :anything, if: -> { true } reproducer. Done means the lambda-based :if expose works without the wrong-number-of-arguments error.
Written by the indexing model from the issue text.
Description
I updated to Ruby 2.4.1 and grape-entity started complaining about using a lambda with :if.
This worked perfectly on Ruby 2.4.0, grape 0.19.2 and grape-entity 0.6.1:
expose :context_company_id, if: -> { company_context? }
It doesn't help if I reduce the problem, this is still broken:
expose :anything, if: -> { true }
Using Ruby 2.4.1 the following error message appears instead:
caught error of type ArgumentError in after callback inside Grape::Middleware::Formatter : wrong number of arguments (given 2, expected 0)
I tried to attach a debugger at entity.rb:477, but I don't know how to figure out options. If I try to inspect it, it'll throw the same error. If I print it, it's very long and I have no idea what to look for.
def exec_with_object(options, &block)
debugger
instance_exec(object, options, &block)
end
(byebug) pp options.inspect
*** ArgumentError Exception: wrong number of arguments (given 2, expected 0)
Any ideas?
- Dominant language
- Ruby
- Stars
- 729
- Forks
- 154
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ruby-grape/grape-entity
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
ruby-grape/grape-entity#386 · 7 comments · 1 reaction ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
ruby-grape/grape-entity#382 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
ruby-grape/grape-entity#380 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
ruby-grape/grape-entity#373 · 2 comments ·
-
Truncate Formatter Open
Difficulty 1/5 1-3 hours Newbie friendliness 45/100
ruby-grape/grape-entity#372 ·
All issues in ruby-grape/grape-entity
Similar issues
-
user-reported
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Kong/developer.konghq.com#7316 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
TheOdinProject/curriculum#31408 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
bensheldon/good_job#1816 · 5 comments ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
notch8/utk_knapsack#148 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
Homebrew/homebrew-cask#288729 · 1 comment ·