Class: Gcloud::Storage::Bucket::Cors
- Inherits:
-
Array
- Object
- Array
- Gcloud::Storage::Bucket::Cors
- Defined in:
- lib/gcloud/storage/bucket/cors.rb
Overview
# Bucket Cors
A special-case Array for managing the website CORS rules for a bucket. Accessed via #cors.
Defined Under Namespace
Classes: Rule
Class Method Summary collapse
Instance Method Summary collapse
-
#add_rule(origin, methods, headers: nil, max_age: nil) ⇒ Object
Add a CORS rule to the CORS rules for a bucket.
- #changed? ⇒ Boolean
- #freeze ⇒ Object
-
#initialize(rules = []) ⇒ Cors
constructor
Initialize a new CORS rules builder with existing CORS rules, if any.
- #to_gapi ⇒ Object
Constructor Details
#initialize(rules = []) ⇒ Cors
Initialize a new CORS rules builder with existing CORS rules, if any.
53 54 55 56 |
# File 'lib/gcloud/storage/bucket/cors.rb', line 53 def initialize rules = [] super rules @original = to_gapi.map(&:to_json) end |
Class Method Details
Instance Method Details
#add_rule(origin, methods, headers: nil, max_age: nil) ⇒ Object
Add a CORS rule to the CORS rules for a bucket. Accepts options for setting preflight response headers. Preflight requests and responses are required if the request method and headers are not both [simple methods](www.w3.org/TR/cors/#simple-method) and [simple headers](www.w3.org/TR/cors/#simple-header).
100 101 102 |
# File 'lib/gcloud/storage/bucket/cors.rb', line 100 def add_rule origin, methods, headers: nil, max_age: nil push Rule.new(origin, methods, headers: headers, max_age: max_age) end |
#changed? ⇒ Boolean
59 60 61 |
# File 'lib/gcloud/storage/bucket/cors.rb', line 59 def changed? @original != to_gapi.map(&:to_json) end |
#freeze ⇒ Object
116 117 118 119 |
# File 'lib/gcloud/storage/bucket/cors.rb', line 116 def freeze each(&:freeze) super end |
#to_gapi ⇒ Object
105 106 107 |
# File 'lib/gcloud/storage/bucket/cors.rb', line 105 def to_gapi map(&:to_gapi) end |