You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix false ArgumentError when using &: with delegated or method_missing methods (#406)
Using `expose :attr, &:method_name` raised a confusing ArgumentError for methods
created via ActiveSupport `delegate` or `method_missing`, because those wrappers
report a variable arity that was misread as "requires arguments."
The arity check now uses Method#parameters instead of Method#arity for precise
detection of required positional and keyword arguments. Methods that cannot be
introspected (delegation wrappers, method_missing proxies without respond_to_missing?)
fall through gracefully and let Ruby raise its native error at call time. The
Proc#to_s regex is strict-anchored to avoid false positives on other lambda shapes.
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,7 @@
8
8
9
9
* Your contribution here.
10
10
*[#404](https://github.com/ruby-grape/grape-entity/pull/404): Drop `MultiJson` dependency, use `Hash#to_json` for ActiveSupport-aware serialization - [@numbata](https://github.com/numbata).
11
+
*[#406](https://github.com/ruby-grape/grape-entity/pull/406): Handle symbol-to-proc wrappers (`&:method_name`) where the method uses `delegate` or `method_missing`, and let unknown methods raise a native `NoMethodError` - [@marcrohloff](https://github.com/marcrohloff).
0 commit comments