Skip to content

Instantly share code, notes, and snippets.

@Ruxton
Created December 1, 2010 01:05
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 Ruxton/722753 to your computer and use it in GitHub Desktop.
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?
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