Class: Ahora::Response
- Inherits:
-
Representation
- Object
- Nibbler
- Representation
- Ahora::Response
- Defined in:
- lib/ahora/representation.rb
Direct Known Subclasses
Constant Summary
Constants inherited from Representation
Ahora::Representation::BOOL_PARSER, Ahora::Representation::DATE_PARSER, Ahora::Representation::FLOAT_PARSER, Ahora::Representation::INTEGER_PARSER, Ahora::Representation::STRING_PARSER, Ahora::Representation::TIME_PARSER
Instance Method Summary collapse
- #cache_key ⇒ Object
-
#initialize(instantiator, document_parser, response) ⇒ Response
constructor
A new instance of Response.
- #target ⇒ Object
Methods included from Ahora::Representation::Definition
#attribute, #attribute_selector, #boolean, #date, #element, #float, #integer, #string, #time
Constructor Details
#initialize(instantiator, document_parser, response) ⇒ Response
Returns a new instance of Response.
101 102 103 104 105 106 |
# File 'lib/ahora/representation.rb', line 101 def initialize(instantiator, document_parser, response) @instantiator = instantiator @document_parser = document_parser @response = response super(target) end |
Instance Method Details
#cache_key ⇒ Object
112 113 114 115 116 |
# File 'lib/ahora/representation.rb', line 112 def cache_key uri = @response.env[:url].dup uri.host = @response.env['HTTP_HOST'] if @response.env['HTTP_HOST'] "#{Digest::SHA1.hexdigest(uri.normalize.to_s)}/#{Digest::SHA1.hexdigest(@response.body)}" end |
#target ⇒ Object
108 109 110 |
# File 'lib/ahora/representation.rb', line 108 def target @instantiator.call @document_parser.call(@response.body) end |