Class: Google::Cloud::Storage::Bucket::Cors::Rule

Inherits:
Object
  • Object
show all
Defined in:
lib/google/cloud/storage/bucket/cors.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(origin, methods, headers: nil, max_age: nil) ⇒ Rule

Returns a new instance of Rule.



124
125
126
127
128
129
# File 'lib/google/cloud/storage/bucket/cors.rb', line 124

def initialize origin, methods, headers: nil, max_age: nil
  @origin = Array(origin)
  @methods = Array(methods)
  @headers = Array(headers)
  @max_age = (max_age||1800)
end

Instance Attribute Details

#headersObject

Returns the value of attribute headers.



122
123
124
# File 'lib/google/cloud/storage/bucket/cors.rb', line 122

def headers
  @headers
end

#max_ageObject

Returns the value of attribute max_age.



122
123
124
# File 'lib/google/cloud/storage/bucket/cors.rb', line 122

def max_age
  @max_age
end

#methodsObject

Returns the value of attribute methods.



122
123
124
# File 'lib/google/cloud/storage/bucket/cors.rb', line 122

def methods
  @methods
end

#originObject

Returns the value of attribute origin.



122
123
124
# File 'lib/google/cloud/storage/bucket/cors.rb', line 122

def origin
  @origin
end

Class Method Details

.from_gapi(gapi) ⇒ Object



138
139
140
141
142
# File 'lib/google/cloud/storage/bucket/cors.rb', line 138

def self.from_gapi gapi
  new gapi.origin.dup, gapi.http_method.dup, \
      headers: gapi.response_header.dup,
      max_age: gapi.max_age_seconds
end

Instance Method Details

#freezeObject



144
145
146
147
148
149
# File 'lib/google/cloud/storage/bucket/cors.rb', line 144

def freeze
  @origin.freeze
  @methods.freeze
  @headers.freeze
  super
end

#to_gapiObject



131
132
133
134
135
136
# File 'lib/google/cloud/storage/bucket/cors.rb', line 131

def to_gapi
  Google::Apis::StorageV1::Bucket::CorsConfiguration.new(
    origin: Array(origin).dup, http_method: Array(methods).dup,
    response_header: Array(headers).dup, max_age_seconds: max_age
  )
end