mirror of https://github.com/fspc/BikeShed-1.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
735 B
26 lines
735 B
class BikeCsvImporter
|
|
module Cache
|
|
def cached_bike_purpose(purpose)
|
|
@bike_purpose_cache ||= {}
|
|
@bike_purpose_cache[purpose] ||= BikePurpose.find_by_purpose purpose
|
|
end
|
|
|
|
def cached_bike_brand(brand)
|
|
@bike_brand_cache ||= {}
|
|
if @bike_brand_cache.has_key? brand
|
|
@bike_brand_cache[brand]
|
|
else
|
|
@bike_brand_cache[brand] = BikeBrand.where('lower(brand) = ?', brand.downcase).first
|
|
end
|
|
end
|
|
|
|
def cached_bike_model(model)
|
|
@bike_model_cache ||= {}
|
|
if @bike_model_cache.has_key? model
|
|
@bike_model_cache[model]
|
|
else
|
|
@bike_model_cache[model] = BikeModel.where('lower(model) = ?', model.downcase).first
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|