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
|