Module: DataMapper::Is::Tagger::InstanceMethods
- Defined in:
- lib/dm-is-taggable/is/tagger.rb
Overview
ClassMethods
Instance Method Summary collapse
Instance Method Details
#tag(object, options = {}) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/dm-is-taggable/is/tagger.rb', line 50 def tag(object, ={}) raise "Object of type #{object.class} isn't taggable!" unless self.taggable_object_classes.include?(object.class) = [:with] = [] if .class != Array .each do |tag| join_row_class = Extlib::Inflection::constantize("#{object.class.to_s}Tag") join_row = join_row_class.new(:tag => tag, Extlib::Inflection::underscore(self.class.to_s).intern => self) object.send("#{Extlib::Inflection::underscore(object.class.to_s)}_tags") << join_row join_row.save end end |