Class: Configuration::Thumbnail::ThumbnailSpec
- Inherits:
-
HandlerStatement
- Object
- HandlerStatement
- Configuration::Thumbnail::ThumbnailSpec
- Includes:
- ConditionalInclusion, ImageName
- Defined in:
- lib/httpimagestore/configuration/thumbnailer.rb
Instance Attribute Summary
Attributes inherited from HandlerStatement
Instance Method Summary collapse
-
#initialize(image_name, method, width, height, format, options = {}, matcher = nil) ⇒ ThumbnailSpec
constructor
A new instance of ThumbnailSpec.
- #render(locals = {}) ⇒ Object
Methods inherited from HandlerStatement
Constructor Details
#initialize(image_name, method, width, height, format, options = {}, matcher = nil) ⇒ ThumbnailSpec
Returns a new instance of ThumbnailSpec.
68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/httpimagestore/configuration/thumbnailer.rb', line 68 def initialize(image_name, method, width, height, format, = {}, matcher = nil) super(nil, image_name, matcher) @method = method.to_template.with_missing_resolver{|locals, key| raise NoValueForSpecTemplatePlaceholerError.new(image_name, 'method', key, method)} @width = width.to_s.to_template.with_missing_resolver{|locals, key| raise NoValueForSpecTemplatePlaceholerError.new(image_name, 'width', key, width)} @height = height.to_s.to_template.with_missing_resolver{|locals, key| raise NoValueForSpecTemplatePlaceholerError.new(image_name, 'height', key, height)} @format = format.to_template.with_missing_resolver{|locals, key| raise NoValueForSpecTemplatePlaceholerError.new(image_name, 'format', key, format)} = .merge() do |option, old, template| template.to_s.to_template.with_missing_resolver{|locals, field| raise NoValueForSpecTemplatePlaceholerError.new(image_name, option, field, template)} end end |
Instance Method Details
#render(locals = {}) ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/httpimagestore/configuration/thumbnailer.rb', line 80 def render(locals = {}) = .inject({}){|h, v| h[v.first] = v.last.render(locals); h} = ['options'] ? Hash[.delete('options').to_s.split(',').map{|pair| pair.split(':', 2)}] : {} { image_name => [ @method.render(locals), @width.render(locals), @height.render(locals), @format.render(locals), .merge() ] } end |