Skip to content

Commit

Permalink
grab (#739)
Browse files Browse the repository at this point in the history
resolves #720
  • Loading branch information
joeldrapper authored Jul 2, 2024
2 parents d5fb7ea + 364cd86 commit 82e4a49
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/phlex/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,12 @@ def mix(*args)
end
end
end

def grab(**bindings)
if bindings.size > 1
bindings.values
else
bindings.values.first
end
end
end
13 changes: 13 additions & 0 deletions quickdraw/helpers/grap.test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

include Phlex::Helpers

test "supports many bindings" do
output = grab({ class: "foo" }, { if: "bar" })
expect(output) == ["foo", "bar"]
end

test "supports single binding" do
output = grab({ class: "foo" })
expect(output) == ["foo"]
end

0 comments on commit 82e4a49

Please sign in to comment.