Commit 2ec5246
authored
Fix ArgumentError for single-argument lambdas in expose and conditions (#399)
## Summary
Upgrading to 1.0.2 breaks commonly used single-argument lambda patterns
in `expose` blocks and `if:` conditions:
```ruby
expose :property, if: ->(model) { model.active? }
expose :storage, if: ->(model) { model.storage_method.present? } do |model|
check_storage(model, :storage_method)
end
```
These raise `ArgumentError: wrong number of arguments (given 2, expected
1)` since v1.0.2.
This PR restores support for single-argument lambdas while preserving
the symbol-to-proc (`&:method`) validation introduced in #389. Users who
already applied the two-argument workaround (`->(model, _) { ... }`) are
not affected — both styles work.
Reported in #398.1 parent bb355c8 commit 2ec5246
File tree
3 files changed
+80
-9
lines changed- lib/grape_entity
- spec/grape_entity
3 files changed
+80
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
525 | 525 | | |
526 | 526 | | |
527 | 527 | | |
528 | | - | |
529 | | - | |
530 | | - | |
531 | | - | |
532 | | - | |
533 | | - | |
534 | | - | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
535 | 532 | | |
536 | 533 | | |
537 | 534 | | |
| |||
542 | 539 | | |
543 | 540 | | |
544 | 541 | | |
545 | | - | |
| 542 | + | |
546 | 543 | | |
547 | 544 | | |
548 | 545 | | |
| |||
551 | 548 | | |
552 | 549 | | |
553 | 550 | | |
554 | | - | |
| 551 | + | |
555 | 552 | | |
556 | 553 | | |
557 | 554 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
30 | 35 | | |
31 | 36 | | |
32 | 37 | | |
| |||
148 | 153 | | |
149 | 154 | | |
150 | 155 | | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
151 | 162 | | |
152 | 163 | | |
153 | 164 | | |
| |||
476 | 487 | | |
477 | 488 | | |
478 | 489 | | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
479 | 526 | | |
480 | 527 | | |
481 | 528 | | |
| |||
521 | 568 | | |
522 | 569 | | |
523 | 570 | | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
524 | 597 | | |
525 | 598 | | |
526 | 599 | | |
| |||
0 commit comments