Class: Configuration::OutputImage
- Inherits:
-
Object
- Object
- Configuration::OutputImage
- Includes:
- ClassLogging
- Defined in:
- lib/httpimagestore/configuration/output.rb
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, cache_control) ⇒ OutputImage
constructor
A new instance of OutputImage.
- #realize(request_state) ⇒ Object
Constructor Details
#initialize(name, cache_control) ⇒ OutputImage
Returns a new instance of OutputImage.
144 145 146 147 |
# File 'lib/httpimagestore/configuration/output.rb', line 144 def initialize(name, cache_control) @name = name @cache_control = cache_control end |
Class Method Details
.match(node) ⇒ Object
133 134 135 |
# File 'lib/httpimagestore/configuration/output.rb', line 133 def self.match(node) node.name == 'output_image' end |
.parse(configuration, node) ⇒ Object
137 138 139 140 141 142 |
# File 'lib/httpimagestore/configuration/output.rb', line 137 def self.parse(configuration, node) configuration.output and raise StatementCollisionError.new(node, 'output') image_name = node.grab_values('image name').first cache_control = node.grab_attributes('cache-control').first configuration.output = self.new(image_name, cache_control) end |
Instance Method Details
#realize(request_state) ⇒ Object
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/httpimagestore/configuration/output.rb', line 149 def realize(request_state) image = request_state.images[@name] mime_type = if image.mime_type image.mime_type else log.warn "image '#{@name}' has no mime type; sending 'application/octet-stream' content type" 'application/octet-stream' end cache_control = @cache_control request_state.output do res['Cache-Control'] = cache_control if cache_control write 200, mime_type, image.data end end |