Module: Annotations::Acts::Annotatable::SingletonMethods
- Defined in:
- lib/annotations/acts_as_annotatable.rb
Overview
Class methods added to the model that has been made acts_as_annotatable (ie: the mixin target class).
Instance Method Summary collapse
-
#find_annotations_by(source_type, source_id, include_values = false) ⇒ Object
Helper finder to get all annotations for all objects of the mixin annotatable type, by the source specified.
-
#find_annotations_for(id, include_values = false) ⇒ Object
Helper finder to get all annotations for an object of the mixin annotatable type with the ID provided.
Instance Method Details
#find_annotations_by(source_type, source_id, include_values = false) ⇒ Object
Helper finder to get all annotations for all objects of the mixin annotatable type, by the source specified. E.g: Book.find_annotations_by(‘User’, 10) will give all annotations for all Books by User with ID 10.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/annotations/acts_as_annotatable.rb', line 53 def find_annotations_by(source_type, source_id, include_values=false) obj_type = ActiveRecord::Base.send(:class_name_of_active_record_descendant, self).to_s = { :conditions => { :annotatable_type => obj_type, :source_type => source_type, :source_id => source_id }, :order => "updated_at DESC" } [:include] = [ :value ] if include_values Annotation.find(:all, ) end |
#find_annotations_for(id, include_values = false) ⇒ Object
Helper finder to get all annotations for an object of the mixin annotatable type with the ID provided. This is the same as object.annotations with the added benefit that the object doesnt have to be loaded. E.g: Book.find_annotations_for(34) will give all annotations for the Book with ID 34.
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/annotations/acts_as_annotatable.rb', line 37 def find_annotations_for(id, include_values=false) obj_type = ActiveRecord::Base.send(:class_name_of_active_record_descendant, self).to_s = { :conditions => { :annotatable_type => obj_type, :annotatable_id => id }, :order => "updated_at DESC" } [:include] = [ :value ] if include_values Annotation.find(:all, ) end |