Module: ActsAsOrganizable::TaggableMethods

Defined in:
lib/acts_as_organizable.rb

Defined Under Namespace

Modules: InstanceMethods

Class Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/acts_as_organizable.rb', line 44

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

    has_many :taggings, :as => :taggable, :dependent => :destroy
    has_many :tags, :through => :taggings
    before_save :cache_tags

    tag_kinds.each do |k|
      # Example: language gets passed in and becomes language_list
      define_method("#{k}_list") { get_tag_list(k) }
      # this is expexting language_list = "spanish, italian" 
      define_method("#{k}_list=") { |new_list| set_tag_list(k, new_list.clean_up_tags) }
    end
  end
end