Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow all possible args in tagged_with method #2211

Merged
merged 1 commit into from
Nov 18, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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