Module: ActiveRecord::Acts::Tagger::InstanceMethods

Defined in:
lib/acts_as_taggable_on/acts_as_tagger.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



23
24
# File 'lib/acts_as_taggable_on/acts_as_tagger.rb', line 23

def self.included(base)
end

Instance Method Details

#is_tagger?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/acts_as_taggable_on/acts_as_tagger.rb', line 39

def is_tagger?
  self.class.is_tagger?
end

#tag(taggable, opts = {}) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/acts_as_taggable_on/acts_as_tagger.rb', line 26

def tag(taggable, opts={})
  opts.reverse_merge!(:force => true)

  return false unless taggable.respond_to?(:is_taggable?) && taggable.is_taggable?
  raise "You need to specify a tag context using :on" unless opts.has_key?(:on)
  raise "You need to specify some tags using :with" unless opts.has_key?(:with)
  raise "No context :#{opts[:on]} defined in #{taggable.class.to_s}" unless 
      ( opts[:force] || taggable.tag_types.include?(opts[:on]) )

  taggable.set_tag_list_on(opts[:on].to_s, opts[:with], self)
  taggable.save
end