Module: Tagtical::Tagger::ClassMethods

Defined in:
lib/tagtical/acts_as_tagger.rb

Instance Method Summary collapse

Instance Method Details

#acts_as_tagger(opts = {}) ⇒ Object

Make a model a tagger. This allows an instance of a model to claim ownership of tags.

Example:

class User < ActiveRecord::Base
  acts_as_tagger
end


16
17
18
19
20
21
22
23
24
25
26
# File 'lib/tagtical/acts_as_tagger.rb', line 16

def acts_as_tagger(opts={})
  class_eval do
    opts.update(:as => :tagger) if Tagtical.config.polymorphic_tagger?
    has_many :owned_taggings, opts.merge(:dependent => :destroy,
                                         :include => :tag, :class_name => "Tagtical::Tagging")
    has_many :owned_tags, :through => :owned_taggings, :source => :tag, :uniq => true, :class_name => "Tagtical::Tag"
  end

  include Tagtical::Tagger::InstanceMethods
  extend Tagtical::Tagger::SingletonMethods
end

#is_tagger?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/tagtical/acts_as_tagger.rb', line 28

def is_tagger?
  false
end