Created
December 17, 2012 23:19
-
-
Save taylorlapeyre/4323387 to your computer and use it in GitHub Desktop.
Basic outline / idea for a Gallery model
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
class Gallery | |
attr_reader :id, :name, :description, :images, :default_image_id | |
def initialize(id, name, description, images={}) | |
@id = id | |
@name = name | |
@description = description | |
@images = images | |
end | |
def add_image(image) # Takes a GalleryImage | |
@images[@images.size + 1] = image | |
end | |
def remove_image(image_id) | |
@images.delete(image_id) | |
end | |
def set_default_image(image_id) | |
@default_image_id = image_id | |
end | |
def show_images | |
@images.each do |image| | |
image.display_with_html | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment