Created
January 13, 2009 09:54
-
-
Save slawosz/46385 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module GallerySlicePhotos | |
def self.included(base) | |
base.class_eval do | |
include GallerySlicePhotos::InstanceMethods | |
extend GallerySlicePhotos::DMClassMethods | |
end | |
end | |
module DMClassMethods | |
def self.extended(base) | |
base.class_eval do | |
property :gallery_id, Integer | |
end | |
end | |
end | |
module InstanceMethods | |
def add_photos(photos) | |
photos.each do |v| | |
Photo.create(:file => v, :gallery_id => self.id) unless v.blank? | |
end | |
end | |
def new_photos | |
self.photos.all( :new => true ) | |
end | |
def photos | |
Photo.all( :gallery_id => self.gallery_id ) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment