Class: HasFilepickerImage::UrlBuilder::ApiOptions
- Inherits:
-
HashWithIndifferentAccess
- Object
- HashWithIndifferentAccess
- HasFilepickerImage::UrlBuilder::ApiOptions
- Defined in:
- lib/has_filepicker_image/url_builder.rb
Constant Summary collapse
- CONVERSION_OPTIONS =
[:w, :h, :fit]
- RETRIEVAL_OPTIONS =
[:dl, :cache]
- DEFAULT_OPTIONS =
{:cache => true, :dl => 'false', :fit => 'max'}
- ALL_OPTIONS =
RETRIEVAL_OPTIONS + CONVERSION_OPTIONS
Instance Method Summary collapse
-
#initialize(styles, hash_or_style = {}, hash = {}) ⇒ ApiOptions
constructor
A new instance of ApiOptions.
- #with_conversion_options? ⇒ Boolean
Constructor Details
#initialize(styles, hash_or_style = {}, hash = {}) ⇒ ApiOptions
Returns a new instance of ApiOptions.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/has_filepicker_image/url_builder.rb', line 36 def initialize(styles, hash_or_style = {}, hash = {}) @styles = styles = if hash_or_style.is_a?(Hash) hash_or_style.assert_valid_keys(*ALL_OPTIONS) hash_or_style else hash.assert_valid_keys(*ALL_OPTIONS) (hash_or_style).merge(hash) end merge! merge! defaults.except *.keys.map(&:to_sym) end |
Instance Method Details
#with_conversion_options? ⇒ Boolean
51 52 53 |
# File 'lib/has_filepicker_image/url_builder.rb', line 51 def (keys.map(&:to_sym) & CONVERSION_OPTIONS).present? end |