Skip to content

Commit

Permalink
Merge pull request #2211 from robinboening/extend_tagged_with_interface
Browse files Browse the repository at this point in the history
Allow all possible args in tagged_with method
  • Loading branch information
tvdeyen authored Nov 18, 2021
2 parents e758528 + eafb1cd commit 32c7a1e
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions lib/alchemy/taggable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,20 @@ 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)

unless args[:match]
args.merge!(match: :all)
end

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

super(args)
end

# Returns all unique tags
Expand Down

0 comments on commit 32c7a1e

Please sign in to comment.