Module: ActsAsTaggableOn::Taggable

Defined in:
lib/acts_as_taggable_on/acts_as_taggable_on/dirty.rb,
lib/acts_as_taggable_on/social_stream.rb

Defined Under Namespace

Modules: Dirty

Instance Method Summary collapse

Instance Method Details

#acts_as_taggable_on(*tag_types) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/acts_as_taggable_on/social_stream.rb', line 4

def acts_as_taggable_on(*tag_types)
  tag_types = tag_types.to_a.flatten.compact.map(&:to_sym)

  if taggable?
    write_inheritable_attribute(:tag_types, (self.tag_types + tag_types).uniq)
  else
    write_inheritable_attribute(:tag_types, tag_types)
    class_inheritable_reader(:tag_types)

    class_eval do
      has_many :taggings, :as => :taggable, :dependent => :destroy, :include => :tag, :class_name => "ActsAsTaggableOn::Tagging"
      has_many :base_tags, :through => :taggings, :source => :tag, :class_name => "ActsAsTaggableOn::Tag"

      def self.taggable?
        true
      end

      include ActsAsTaggableOn::Taggable::Core
      include ActsAsTaggableOn::Taggable::Collection
      include ActsAsTaggableOn::Taggable::Cache
      include ActsAsTaggableOn::Taggable::Ownership
      include ActsAsTaggableOn::Taggable::Related
      include ActsAsTaggableOn::Taggable::Dirty
    end
  end
end