Class: Rack::Cache::Key
Class Attribute Summary collapse
-
.query_string_ignore ⇒ Object
Returns the value of attribute query_string_ignore.
Class Method Summary collapse
-
.call(request) ⇒ Object
Implement .call, since it seems like the “Rack-y” thing to do.
Instance Method Summary collapse
-
#generate ⇒ Object
Generate a normalized cache key for the request.
-
#initialize(request) ⇒ Key
constructor
A new instance of Key.
Constructor Details
#initialize(request) ⇒ Key
Returns a new instance of Key.
28 29 30 |
# File 'lib/rack/cache/key.rb', line 28 def initialize(request) @request = request end |
Class Attribute Details
.query_string_ignore ⇒ Object
Returns the value of attribute query_string_ignore.
19 20 21 |
# File 'lib/rack/cache/key.rb', line 19 def query_string_ignore @query_string_ignore end |
Class Method Details
.call(request) ⇒ Object
Implement .call, since it seems like the “Rack-y” thing to do. Plus, it opens the door for cache key generators to just be blocks.
24 25 26 |
# File 'lib/rack/cache/key.rb', line 24 def self.call(request) new(request).generate end |
Instance Method Details
#generate ⇒ Object
Generate a normalized cache key for the request.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/rack/cache/key.rb', line 33 def generate parts = [] parts << @request.scheme << "://" parts << @request.host if @request.scheme == "https" && @request.port != 443 || @request.scheme == "http" && @request.port != 80 parts << ":" << @request.port.to_s end parts << @request.script_name parts << @request.path_info if qs = query_string parts << "?" parts << qs end parts.join end |