Module: Polygallery::HasPolyphotos::LocalInstanceMethods
- Defined in:
- lib/polygallery/has_polyphotos.rb
Instance Method Summary collapse
- #build_first_photo ⇒ Object
- #include_polygallery_settings(settings) ⇒ Object
- #initialize_polygallery ⇒ Object
- #polygallery_photos ⇒ Object
- #polygallery_settings ⇒ Object
- #set_nest(photo) ⇒ Object
Instance Method Details
#build_first_photo ⇒ Object
68 69 70 71 72 73 74 75 76 |
# File 'lib/polygallery/has_polyphotos.rb', line 68 def build_first_photo photo_association = self.polygallery_photos photo_association.build( :polygallery_options => self.polygallery_settings, :galleryable => self.galleryable, :galleryable_id => self.galleryable_id, :galleryable_type => self.galleryable_type, :gallery_title => self.title ) unless photo_association.any? end |
#include_polygallery_settings(settings) ⇒ Object
58 59 60 61 |
# File 'lib/polygallery/has_polyphotos.rb', line 58 def include_polygallery_settings(settings) self. = settings self.initialize_polygallery end |
#initialize_polygallery ⇒ Object
63 64 65 66 |
# File 'lib/polygallery/has_polyphotos.rb', line 63 def initialize_polygallery settings = self.polygallery_settings self.class.init_associations(settings) end |
#polygallery_photos ⇒ Object
85 86 87 |
# File 'lib/polygallery/has_polyphotos.rb', line 85 def polygallery_photos self.send self.polygallery_settings[:association_names][:photos] end |
#polygallery_settings ⇒ Object
78 79 80 81 82 83 |
# File 'lib/polygallery/has_polyphotos.rb', line 78 def polygallery_settings return self. if self..present? return Kernel.const_get(self.galleryable_type) .send(:"#{self.title}_settings") if galleryable_type.present? self.class.polygallery_settings end |
#set_nest(photo) ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'lib/polygallery/has_polyphotos.rb', line 48 def set_nest(photo) photo.galleryable_id ||= galleryable_id photo.galleryable_type ||= galleryable_type photo.galleryable ||= galleryable photo.gallery_title ||= title photo. = self.polygallery_settings photo.initialize_polyphoto photo.send(:"#{title}=", self) if photo.send(:"#{title}").nil? end |