Skip to content

Commit

Permalink
Allow all possible args in tagged_with method
Browse files Browse the repository at this point in the history
Previously, we only allowed tag names to be passed into the `tagged_with` method. This commit allows to take advantage of the interface gutentag has to offer, while being backwards compatible.
  • Loading branch information
robinboening committed Nov 5, 2021
1 parent eb50acb commit bc42f3a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/alchemy/taggable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@ def tag_list=(tags)
end

module ClassMethods
# Find all records matching all of the given tags.
# Separate multiple tags by comma.
def tagged_with(names)
def tagged_with(names = [], **args)
if names.is_a? String
names = names.split(/,\s*/)
end
super(names: names, match: :all)

if names.any?
args.merge!(names: names)
end

super(args)
end

# Returns all unique tags
Expand Down

0 comments on commit bc42f3a

Please sign in to comment.