Sha256: b45e5b7a5ec19683b96dee0b6529b32f12d9a3f8037d310481529a1b7b850eb7
Contents?: true
Size: 1.32 KB
Versions: 2
Compression:
Stored size: 1.32 KB
Contents
module ActiveMetadata::Persistence::ActiveRecord::Note def self.included(receiver) receiver.send :include, InstanceMethods end module InstanceMethods def create_note_for(field, note) Note.create! :document_id => metadata_id,:label => field.to_s,:note => note, :created_by => current_user_id self.send(:send_notification, field, "", note, :note_message, current_user_id) end def update_note(id, note) n = Note.find(id) old_value = n.note n.update_attributes! :note => note, :updated_by => current_user_id, :updated_at => Time.now.utc self.send(:send_notification, n.label, old_value, note, :note_message, current_user_id) end def notes_for(field) Note.all(:conditions => {:label => field, :document_id => metadata_id}, :order => "updated_at DESC" ) end def note_for(field,id) Note.find(id) end def create_notes_for(field,notes) notes.each { |note| create_note_for field, note } end def delete_note_for(field,id) n = Note.find(id) old_value = n.note n.destroy self.send(:send_notification, field, old_value, "", :note_message) end def has_notes_for field Note.count(:conditions => {:label => field, :document_id => metadata_id}) == 0 ? false : true end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
active_metadata-0.2.0 | lib/active_metadata/persistence/active_record/note.rb |
active_metadata-0.1.9 | lib/active_metadata/persistence/active_record/note.rb |