Module: MakeTaggable::Taggable

Defined in:
lib/make_taggable/taggable.rb,
lib/make_taggable/taggable/core.rb,
lib/make_taggable/taggable/cache.rb,
lib/make_taggable/taggable/related.rb,
lib/make_taggable/taggable/ownership.rb,
lib/make_taggable/taggable/collection.rb

Overview

Declaring a model taggable. Mixed into Active Record automatically, which is what puts #make_taggable on every model.

Defined Under Namespace

Modules: Cache, Collection, Core, Ownership, Related, TaggedWithQuery

Instance Method Summary collapse

Instance Method Details

#make_ordered_taggable(*tag_types) ⇒ void

This method returns an undefined value.

Make a model taggable on the given contexts, preserving the order in which tags were added.

Called without arguments it makes the model taggable on :tags.

Examples:

class User < ActiveRecord::Base
  make_ordered_taggable :languages, :skills
end

Parameters:

  • tag_types (Array<Symbol, String>)

    the contexts to tag on



56
57
58
59
60
# File 'lib/make_taggable/taggable.rb', line 56

def make_ordered_taggable(*tag_types)
  tag_types = [:tags] if tag_types.flatten.compact.empty?

  taggable_on(true, tag_types)
end

#make_taggable(*tag_types) ⇒ void

This method returns an undefined value.

Make a model taggable on the given contexts.

Called without arguments it makes the model taggable on :tags, which is the context every other part of the library treats as the default.

Examples:

A single, default context

class Book < ActiveRecord::Base
  make_taggable
end

Several named contexts

class User < ActiveRecord::Base
  make_taggable :languages, :skills
end

Parameters:

  • tag_types (Array<Symbol, String>)

    the contexts to tag on



37
38
39
40
41
# File 'lib/make_taggable/taggable.rb', line 37

def make_taggable(*tag_types)
  tag_types = [:tags] if tag_types.flatten.compact.empty?

  taggable_on(false, tag_types)
end

#taggable?TrueClass, FalseClass

Whether this model has been made taggable.

Returns:



14
15
16
# File 'lib/make_taggable/taggable.rb', line 14

def taggable?
  false
end