Module: Tagtical::Taggable
- Defined in:
- lib/tagtical/taggable.rb,
lib/tagtical/taggable/core.rb,
lib/tagtical/taggable/cache.rb,
lib/tagtical/taggable/related.rb,
lib/tagtical/taggable/ownership.rb,
lib/tagtical/taggable/collection.rb
Defined Under Namespace
Modules: Cache, Collection, Core, Ownership, Related
Instance Method Summary collapse
-
#acts_as_taggable(*tag_types) ⇒ Object
Make a model taggable on specified contexts.
- #taggable? ⇒ Boolean
Instance Method Details
#acts_as_taggable(*tag_types) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/tagtical/taggable.rb', line 22 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 |
#taggable? ⇒ Boolean
3 4 5 |
# File 'lib/tagtical/taggable.rb', line 3 def taggable? false end |