Module: IsTaggable::TaggableMethods

Defined in:
lib/is_taggable.rb

Defined Under Namespace

Modules: InstanceMethods

Class Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/is_taggable.rb', line 32

def self.included(klass)
  klass.class_eval do
    include IsTaggable::TaggableMethods::InstanceMethods

    has_many   :taggings, :as      => :taggable, :dependent => :destroy
    has_many   :tags,     :through => :taggings
    after_save :save_tags

    tag_kinds.each do |k|
      define_method("#{k}_list")  { get_tag_list(k) }
      define_method("#{k}_list=") { |new_list| set_tag_list(k, new_list) }
    end
  end
end