Class: Aliyun::Oss::Struct::Cors
- Defined in:
- lib/aliyun/oss/struct/cors.rb
Constant Summary collapse
- ACCESSPTED_METHODS =
%w(GET PUT DELETE POST HEAD)
Instance Attribute Summary collapse
-
#allowed_header ⇒ Object
Set allowed headers used in preflight (see #bucket_preflight).
-
#allowed_method ⇒ Object
Set allowed methods.
-
#allowed_origin ⇒ Object
Set allowed origins.
-
#expose_header ⇒ Object
Set allowed used response headers for user.
-
#max_age_seconds ⇒ Object
Specifies cache time the browser to pre-fetch a particular resource request in seconds.
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from Aliyun::Oss::Struct::Base
Instance Attribute Details
#allowed_header ⇒ Object
Set allowed headers used in preflight (see #bucket_preflight). [Array]
14 15 16 |
# File 'lib/aliyun/oss/struct/cors.rb', line 14 def allowed_header @allowed_header end |
#allowed_method ⇒ Object
Set allowed methods. [Array]
11 12 13 |
# File 'lib/aliyun/oss/struct/cors.rb', line 11 def allowed_method @allowed_method end |
#allowed_origin ⇒ Object
Set allowed origins. [Array]
8 9 10 |
# File 'lib/aliyun/oss/struct/cors.rb', line 8 def allowed_origin @allowed_origin end |
#expose_header ⇒ Object
Set allowed used response headers for user. [Array]
17 18 19 |
# File 'lib/aliyun/oss/struct/cors.rb', line 17 def expose_header @expose_header end |
#max_age_seconds ⇒ Object
Specifies cache time the browser to pre-fetch a particular resource request in seconds. [Integer]
20 21 22 |
# File 'lib/aliyun/oss/struct/cors.rb', line 20 def max_age_seconds @max_age_seconds end |
Instance Method Details
#to_hash ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/aliyun/oss/struct/cors.rb', line 40 def to_hash return {} unless valid? attrs = { 'AllowedOrigin' => allowed_origin, 'AllowedMethod' => allowed_method } attrs.merge!('AllowedHeader' => allowed_header) if value_present?(allowed_header) attrs.merge!('EsposeHeader' => expose_header) if value_present?(expose_header) attrs.merge!('MaxAgeSeconds' => max_age_seconds) if max_age_seconds attrs end |
#valid? ⇒ Boolean
53 54 55 |
# File 'lib/aliyun/oss/struct/cors.rb', line 53 def valid? value_present?(allowed_origin) && value_present?(allowed_method) end |