Module: Philiprehberger::Etag::Conditional
- Defined in:
- lib/philiprehberger/etag/conditional.rb
Overview
Evaluates If-Modified-Since conditional requests based on timestamps.
Class Method Summary collapse
-
.modified_since?(last_modified, if_modified_since_header) ⇒ Boolean
Checks if a resource has been modified since the given If-Modified-Since header value.
-
.not_modified_since?(last_modified, if_modified_since_header) ⇒ Boolean
Checks if a resource has NOT been modified since the given If-Modified-Since header value.
Class Method Details
.modified_since?(last_modified, if_modified_since_header) ⇒ Boolean
Checks if a resource has been modified since the given If-Modified-Since header value. Compares the resource’s last modified time against the header’s parsed date.
15 16 17 18 19 20 21 22 |
# File 'lib/philiprehberger/etag/conditional.rb', line 15 def self.modified_since?(last_modified, if_modified_since_header) return true if if_modified_since_header.nil? || if_modified_since_header.strip.empty? header_time = parse_time(if_modified_since_header) return true if header_time.nil? last_modified.to_i > header_time.to_i end |
.not_modified_since?(last_modified, if_modified_since_header) ⇒ Boolean
Checks if a resource has NOT been modified since the given If-Modified-Since header value. Convenience inverse of modified_since?.
30 31 32 |
# File 'lib/philiprehberger/etag/conditional.rb', line 30 def self.not_modified_since?(last_modified, if_modified_since_header) !modified_since?(last_modified, if_modified_since_header) end |