Module: Artwork::Configuration
- Included in:
- Artwork
- Defined in:
- lib/artwork/configuration.rb
Instance Method Summary collapse
- #configure_for(request) ⇒ Object
- #current_resolution ⇒ Object
- #current_resolution=(resolution) ⇒ Object
- #default_resolution ⇒ Object
- #default_resolution=(resolution) ⇒ Object
- #load_2x_images=(flag) ⇒ Object
- #load_2x_images? ⇒ Boolean
- #reset_configuration ⇒ Object
- #supported_resolutions_list ⇒ Object
- #supported_resolutions_list=(resolutions) ⇒ Object
Instance Method Details
#configure_for(request) ⇒ Object
39 40 41 42 |
# File 'lib/artwork/configuration.rb', line 39 def configure_for(request) Artwork.load_2x_images = fetch_2x_images_flag_from(request) Artwork.current_resolution = current_resolution_from(request) end |
#current_resolution ⇒ Object
31 32 33 |
# File 'lib/artwork/configuration.rb', line 31 def current_resolution get(:current_resolution) || default_resolution end |
#current_resolution=(resolution) ⇒ Object
35 36 37 |
# File 'lib/artwork/configuration.rb', line 35 def current_resolution=(resolution) set :current_resolution, resolution end |
#default_resolution ⇒ Object
14 15 16 |
# File 'lib/artwork/configuration.rb', line 14 def default_resolution get(:default_resolution) or @@default_resolution or raise "Please set #{__method__}" end |
#default_resolution=(resolution) ⇒ Object
18 19 20 21 |
# File 'lib/artwork/configuration.rb', line 18 def default_resolution=(resolution) @@default_resolution ||= resolution set :default_resolution, resolution end |
#load_2x_images=(flag) ⇒ Object
27 28 29 |
# File 'lib/artwork/configuration.rb', line 27 def load_2x_images=(flag) set :load_2x_images, flag end |
#load_2x_images? ⇒ Boolean
23 24 25 |
# File 'lib/artwork/configuration.rb', line 23 def load_2x_images? get(:load_2x_images) || false end |
#reset_configuration ⇒ Object
44 45 46 47 |
# File 'lib/artwork/configuration.rb', line 44 def reset_configuration set :current_resolution, nil set :load_2x_images, nil end |
#supported_resolutions_list ⇒ Object
3 4 5 |
# File 'lib/artwork/configuration.rb', line 3 def supported_resolutions_list get(:supported_resolutions_list) or @@supported_resolutions_list or raise "Please set #{__method__}" end |
#supported_resolutions_list=(resolutions) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/artwork/configuration.rb', line 7 def supported_resolutions_list=(resolutions) list = resolutions.map(&:to_i).sort @@supported_resolutions_list ||= list set :supported_resolutions_list, list end |