Skip to content

Instantly share code, notes, and snippets.

@slawosz
Created January 13, 2009 09:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slawosz/46385 to your computer and use it in GitHub Desktop.
Save slawosz/46385 to your computer and use it in GitHub Desktop.
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