lib/artwork/configuration.rb in artwork-0.6.1 vs lib/artwork/configuration.rb in artwork-0.7.0

- old
+ new

@@ -9,17 +9,17 @@ @@supported_resolutions_list ||= list set :supported_resolutions_list, list end - def default_resolution - get(:default_resolution) or @@default_resolution or raise "Please set #{__method__}" + def base_resolution + get(:base_resolution) or @@base_resolution or raise "Please set #{__method__}" end - def default_resolution=(resolution) - @@default_resolution ||= resolution - set :default_resolution, resolution + def base_resolution=(resolution) + @@base_resolution ||= resolution + set :base_resolution, resolution end def load_2x_images? get(:load_2x_images) || false end @@ -27,30 +27,29 @@ def load_2x_images=(flag) set :load_2x_images, flag end def current_resolution - get(:current_resolution) || default_resolution + get(:current_resolution) || base_resolution end - def actual_resolution_for(request) - browser_width = request.cookies['_width'].to_i + def current_resolution=(resolution) + set :current_resolution, resolution + end - if browser_width > 0 - browser_width - else - default_resolution - end + def actual_resolution + get(:actual_resolution) || base_resolution end - def current_resolution=(resolution) - set :current_resolution, resolution + def actual_resolution=(resolution) + set :actual_resolution, resolution end def configure_for(request) Artwork.load_2x_images = fetch_2x_images_flag_from(request) Artwork.current_resolution = current_resolution_from(request) + Artwork.actual_resolution = actual_resolution_from(request) end def reset_configuration set :current_resolution, nil set :load_2x_images, nil @@ -71,15 +70,25 @@ end def current_resolution_from(request) browser_width = request.cookies['_width'].to_i - return default_resolution if browser_width.zero? + return base_resolution if browser_width.zero? supported_resolutions_list.each do |resolution| return resolution if browser_width <= resolution end supported_resolutions_list.last + end + + def actual_resolution_from(request) + browser_width = request.cookies['_width'].to_i + + if browser_width > 0 + browser_width + else + base_resolution + end end end end