Class: Rack::Cors::Result
- Inherits:
-
Object
- Object
- Rack::Cors::Result
- Defined in:
- lib/rack/cors/result.rb
Constant Summary collapse
- HEADER_KEY =
'x-rack-cors'
- MISS_NO_ORIGIN =
'no-origin'
- MISS_NO_PATH =
'no-path'
- MISS_NO_METHOD =
'no-method'
- MISS_DENY_METHOD =
'deny-method'
- MISS_DENY_HEADER =
'deny-header'
Instance Attribute Summary collapse
-
#hit ⇒ Object
Returns the value of attribute hit.
-
#miss_reason ⇒ Object
Returns the value of attribute miss_reason.
-
#preflight ⇒ Object
Returns the value of attribute preflight.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#hit ⇒ Object
Returns the value of attribute hit.
15 16 17 |
# File 'lib/rack/cors/result.rb', line 15 def hit @hit end |
#miss_reason ⇒ Object
Returns the value of attribute miss_reason.
15 16 17 |
# File 'lib/rack/cors/result.rb', line 15 def miss_reason @miss_reason end |
#preflight ⇒ Object
Returns the value of attribute preflight.
15 16 17 |
# File 'lib/rack/cors/result.rb', line 15 def preflight @preflight end |
Class Method Details
.hit(env) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/rack/cors/result.rb', line 30 def self.hit(env) r = Result.new r.preflight = false r.hit = true env[Rack::Cors::ENV_KEY] = r end |
Instance Method Details
#append_header(headers) ⇒ Object
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/rack/cors/result.rb', line 51 def append_header(headers) headers[HEADER_KEY] = if hit? preflight? ? 'preflight-hit' : 'hit' else [ (preflight? ? 'preflight-miss' : 'miss'), miss_reason ].join('; ') end end |
#hit? ⇒ Boolean
17 18 19 |
# File 'lib/rack/cors/result.rb', line 17 def hit? !!hit end |
#miss(reason) ⇒ Object
25 26 27 28 |
# File 'lib/rack/cors/result.rb', line 25 def miss(reason) self.hit = false self.miss_reason = reason end |
#preflight? ⇒ Boolean
21 22 23 |
# File 'lib/rack/cors/result.rb', line 21 def preflight? !!preflight end |