Class: Imgproxy::OptionsBuilders::Base
- Inherits:
-
Hash
- Object
- Hash
- Imgproxy::OptionsBuilders::Base
- Defined in:
- lib/imgproxy/options_builders/base.rb
Overview
Formats and regroups URL options
Direct Known Subclasses
Constant Summary collapse
- CASTERS =
Hash of options casters. Redefine this in subclases
{}.freeze
- META =
Array of meta-options names. Redefine this in subclases
[].freeze
Instance Method Summary collapse
-
#initialize(options) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(options) ⇒ Base
Returns a new instance of Base.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/imgproxy/options_builders/base.rb', line 17 def initialize() super() # Options order hack: initialize known and meta options with nil value to preserve order self.class::CASTERS.each_key do |n| self[n] = nil if .key?(n) || self.class::META.include?(n) end .each do |name, value| caster = self.class::CASTERS[name] self[name] = caster ? caster.cast(value) : unwrap_hash(value) end group_opts compact! end |