Sha256: a457e8da3306c1fdda3a6f86a336190126f1e4bcea46a4a1627056609cdfd490
Contents?: true
Size: 1.49 KB
Versions: 2
Compression:
Stored size: 1.49 KB
Contents
module Tagtical module Taggable def taggable? false end ## # Make a model taggable on specified contexts. # # @param [Array] tag_types An array of taggable contexts. These must have an associated subclass under Tag. # # Example: # module Tag # class Language < Tagtical::Tag # end # class Skill < Tagtical::Tag # end # end # class User < ActiveRecord::Base # acts_as_taggable :languages, :skills # end def acts_as_taggable(*tag_types) tag_types.flatten! tag_types << Tagtical::Tag::Type::BASE # always include the base type. tag_types = Tagtical::Tag::Type.register(tag_types.uniq.compact, self) 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 => "Tagtical::Tagging" has_many :tags, :through => :taggings, :class_name => "Tagtical::Tag" def self.taggable? true end include Tagtical::Taggable::Core include Tagtical::Taggable::Collection include Tagtical::Taggable::Cache include Tagtical::Taggable::Ownership include Tagtical::Taggable::Related end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
tagtical-1.1.1 | lib/tagtical/taggable.rb |
tagtical-1.1.0 | lib/tagtical/taggable.rb |