Created
December 1, 2010 01:05
-
-
Save Ruxton/722753 to your computer and use it in GitHub Desktop.
Lib Or Model? You DECIDE! Today on Who Want's To Be A Programmer?
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 Shortlist | |
def initialize(variants) | |
@list_storage = variants | |
if @list_storage.nil? | |
@list_storage = [] | |
end | |
end | |
def add_variant(variant_id) | |
if variant_id.is_a?(Integer) | |
@list_storage << variant_id unless @list_storage.include?(variant_id) | |
end | |
end | |
def remove_variant(variant_id) | |
if variant_id.is_a?(Integer) | |
@list_storage.delete(variant_id) | |
end | |
end | |
def get_variants_by_ids | |
ProductVariant.where(:id => @list_storage) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment