Class: AWS::S3::CORSRule
- Inherits:
-
Object
- Object
- AWS::S3::CORSRule
- Defined in:
- lib/aws/s3/cors_rule.rb
Overview
Represents a single CORS rule for an S3 Bucket.
rule = bucket.cors.first
rule.allowed_methods #=> ['GET', 'HEAD']
rule.allowed_origins #=> ['*']
Instance Attribute Summary collapse
-
#allowed_headers ⇒ Array<String>
readonly
A list of headers allowed in the pre-flight OPTIONS request.
-
#allowed_methods ⇒ Array<String>
readonly
A list of HTTP methods (GET, POST, etc) this role authorizes.
-
#allowed_origins ⇒ Array<String>
readonly
The list of origins allowed to make cross-domain requests to the bucket.
-
#expose_headers ⇒ Array<String>
readonly
The headers that may be accessed cross-domain.
-
#id ⇒ String?
readonly
A user supplied unique identifier for this role.
-
#max_age_seconds ⇒ Integer?
readonly
The time in seconds the browser may cache the pre-flight response.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ CORSRule
constructor
A new instance of CORSRule.
- #to_h ⇒ Hash
Constructor Details
#initialize(options = {}) ⇒ CORSRule
Returns a new instance of CORSRule.
59 60 61 62 63 64 65 66 |
# File 'lib/aws/s3/cors_rule.rb', line 59 def initialize = {} @id = [:id] @allowed_methods = [:allowed_methods] || [] @allowed_origins = [:allowed_origins] || [] @allowed_headers = [:allowed_headers] || [] @max_age_seconds = [:max_age_seconds] @expose_headers = [:expose_headers] || [] end |
Instance Attribute Details
#allowed_headers ⇒ Array<String> (readonly)
Returns A list of headers allowed in the pre-flight OPTIONS request.
82 83 84 |
# File 'lib/aws/s3/cors_rule.rb', line 82 def allowed_headers @allowed_headers end |
#allowed_methods ⇒ Array<String> (readonly)
Returns A list of HTTP methods (GET, POST, etc) this role authorizes.
74 75 76 |
# File 'lib/aws/s3/cors_rule.rb', line 74 def allowed_methods @allowed_methods end |
#allowed_origins ⇒ Array<String> (readonly)
Returns The list of origins allowed to make cross-domain requests to the bucket.
78 79 80 |
# File 'lib/aws/s3/cors_rule.rb', line 78 def allowed_origins @allowed_origins end |
#expose_headers ⇒ Array<String> (readonly)
Returns The headers that may be accessed cross-domain.
89 90 91 |
# File 'lib/aws/s3/cors_rule.rb', line 89 def expose_headers @expose_headers end |
#id ⇒ String? (readonly)
Returns A user supplied unique identifier for this role. Set this when you set or add roles via AWS::S3::CORSRuleCollection.
70 71 72 |
# File 'lib/aws/s3/cors_rule.rb', line 70 def id @id end |
#max_age_seconds ⇒ Integer? (readonly)
Returns The time in seconds the browser may cache the pre-flight response.
86 87 88 |
# File 'lib/aws/s3/cors_rule.rb', line 86 def max_age_seconds @max_age_seconds end |
Instance Method Details
#to_h ⇒ Hash
92 93 94 95 96 97 98 99 100 101 |
# File 'lib/aws/s3/cors_rule.rb', line 92 def to_h h = {} h[:id] = id if id h[:allowed_methods] = allowed_methods h[:allowed_origins] = allowed_origins h[:allowed_headers] = allowed_headers unless allowed_headers.empty? h[:max_age_seconds] = max_age_seconds if max_age_seconds h[:expose_headers] = expose_headers unless expose_headers.empty? h end |