Class: ActsAsTaggableOnMongoid::Taggable::TaggedWithQuery

Inherits:
Object
  • Object
show all
Defined in:
lib/acts_as_taggable_on_mongoid/taggable/tagged_with_query.rb,
lib/acts_as_taggable_on_mongoid/taggable/tagged_with_query/base.rb,
lib/acts_as_taggable_on_mongoid/taggable/tagged_with_query/all_tags_query.rb,
lib/acts_as_taggable_on_mongoid/taggable/tagged_with_query/any_tags_query.rb,
lib/acts_as_taggable_on_mongoid/taggable/tagged_with_query/exclude_tags_query.rb,
lib/acts_as_taggable_on_mongoid/taggable/tagged_with_query/match_all_tags_query.rb

Overview

A class finding all Taggable objects for the passed in tags based on the passed in parameters. Details for how the query will work are in the TaggedWith module.

Defined Under Namespace

Classes: AllTagsQuery, AnyTagsQuery, Base, ExcludeTagsQuery, MatchAllTagsQuery

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(taggable_class, *tags) ⇒ TaggedWithQuery

Returns a new instance of TaggedWithQuery.



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/acts_as_taggable_on_mongoid/taggable/tagged_with_query.rb', line 13

def initialize(taggable_class, *tags)
  new_tags        = tags.dup
  @taggable_class = taggable_class
  @options        = new_tags.extract_options!.dup
  @tags           = new_tags

  cleanup_options

  context         = on_context(*options[:on])
  @tag_definition = taggable_class.tag_types[context]
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



8
9
10
# File 'lib/acts_as_taggable_on_mongoid/taggable/tagged_with_query.rb', line 8

def options
  @options
end

#tag_definitionObject (readonly)

Returns the value of attribute tag_definition.



8
9
10
# File 'lib/acts_as_taggable_on_mongoid/taggable/tagged_with_query.rb', line 8

def tag_definition
  @tag_definition
end

#taggable_classObject (readonly)

Returns the value of attribute taggable_class.



8
9
10
# File 'lib/acts_as_taggable_on_mongoid/taggable/tagged_with_query.rb', line 8

def taggable_class
  @taggable_class
end

#tagsObject (readonly)

Returns the value of attribute tags.



8
9
10
# File 'lib/acts_as_taggable_on_mongoid/taggable/tagged_with_query.rb', line 8

def tags
  @tags
end

Instance Method Details

#buildObject



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/acts_as_taggable_on_mongoid/taggable/tagged_with_query.rb', line 25

def build
  klass = if options[:exclude].present?
            ExcludeTagsQuery
          elsif options[:any].present?
            AnyTagsQuery
          elsif options[:match_all]
            MatchAllTagsQuery
          else
            AllTagsQuery
          end

  klass.new(tag_definition, tag_list, options).build
end