Class: Configuration::OutputText
- Inherits:
-
Object
- Object
- Configuration::OutputText
- Defined in:
- lib/httpimagestore/configuration/output.rb
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(text, status, cache_control) ⇒ OutputText
constructor
A new instance of OutputText.
- #realize(request_state) ⇒ Object
Constructor Details
#initialize(text, status, cache_control) ⇒ OutputText
Returns a new instance of OutputText.
31 32 33 34 35 |
# File 'lib/httpimagestore/configuration/output.rb', line 31 def initialize(text, status, cache_control) @text = RubyStringTemplate.new(text || fail("no text?!")) @status = status || 200 @cache_control = cache_control end |
Class Method Details
.match(node) ⇒ Object
20 21 22 |
# File 'lib/httpimagestore/configuration/output.rb', line 20 def self.match(node) node.name == 'output_text' end |
.parse(configuration, node) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/httpimagestore/configuration/output.rb', line 24 def self.parse(configuration, node) configuration.output and raise StatementCollisionError.new(node, 'output') text = node.grab_values('text').first status, cache_control = *node.grab_attributes('status', 'cache-control') configuration.output = OutputText.new(text, status || 200, cache_control) end |
Instance Method Details
#realize(request_state) ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/httpimagestore/configuration/output.rb', line 37 def realize(request_state) # make sure variables are available in request context status = @status text = @text.render(request_state) cache_control = @cache_control request_state.output do res['Cache-Control'] = cache_control if cache_control write_plain status.to_i, text.to_s end end |