Module: MakeTaggable::Taggable::TaggedWithQuery Private
- Defined in:
- lib/make_taggable/taggable/tagged_with_query.rb,
lib/make_taggable/taggable/tagged_with_query/query_base.rb,
lib/make_taggable/taggable/tagged_with_query/all_tags_query.rb,
lib/make_taggable/taggable/tagged_with_query/any_tags_query.rb,
lib/make_taggable/taggable/tagged_with_query/exclude_tags_query.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Builds the relation behind Core::ClassMethods#tagged_with.
Defined Under Namespace
Classes: AllTagsQuery, AnyTagsQuery, ExcludeTagsQuery, QueryBase
Class Method Summary collapse
-
.build(taggable_model, tag_model, tagging_model, tag_list, options) ⇒ ActiveRecord::Relation
private
Picks the query strategy the options call for and builds the relation.
Class Method Details
.build(taggable_model, tag_model, tagging_model, tag_list, options) ⇒ ActiveRecord::Relation
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Picks the query strategy the options call for and builds the relation.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/make_taggable/taggable/tagged_with_query.rb', line 24 def self.build(taggable_model, tag_model, tagging_model, tag_list, ) if [:exclude].present? && [:match_all].present? raise ArgumentError, ":match_all and :exclude cannot be combined. :match_all selects records carrying only the " \ "given tags and nothing else, :exclude selects records carrying none of them, and there is " \ "no set of records that satisfies both." end if [:exclude].present? ExcludeTagsQuery.new(taggable_model, tag_model, tagging_model, tag_list, ).build elsif [:any].present? AnyTagsQuery.new(taggable_model, tag_model, tagging_model, tag_list, ).build else AllTagsQuery.new(taggable_model, tag_model, tagging_model, tag_list, ).build end end |