Sha256: 2d01cc5769ba82b253d0e728e88b8fa58350af47355dd421a0bec264405a6aae
Contents?: true
Size: 1.47 KB
Versions: 3
Compression:
Stored size: 1.47 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[tag_types.uniq.compact] 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
tagtical-1.0.8 | lib/tagtical/taggable.rb |
tagtical-1.0.7 | lib/tagtical/taggable.rb |
tagtical-1.0.6 | lib/tagtical/taggable.rb |