File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -42,6 +42,28 @@ def field
4242 self
4343 end
4444
45+ # A helper, borrowed from Phlex, that makes it easy to "grab" values
46+ # passed into a method that are reserved keywords. For example, this
47+ # would throw a syntax error because `class` and `end` are reserved:
48+ #
49+ # def foo(end:, class:)
50+ # puts class
51+ # puts end
52+ # end
53+ #
54+ # So you "grab" them like this:
55+ # def foo(end:, class:)
56+ # puts grab(end:)
57+ # puts grab(class:)
58+ # end
59+ private def grab ( **bindings )
60+ if bindings . size > 1
61+ bindings . values
62+ else
63+ bindings . values . first
64+ end
65+ end
66+
4567 # High-performance Kit proxy that wraps field methods with form.render calls.
4668 # Uses Ruby class hooks to define methods at the class level for maximum speed:
4769 # - Methods are defined once per Field class, not per Kit instance
You can’t perform that action at this time.
0 commit comments