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.



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

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.



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

def headers
  @headers
end

#max_ageObject

Returns the value of attribute max_age.



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

def max_age
  @max_age
end

#methodsObject

Returns the value of attribute methods.



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

def methods
  @methods
end

#originObject

Returns the value of attribute origin.



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

def origin
  @origin
end

Class Method Details

.from_gapi(gapi) ⇒ Object



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

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



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

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

#to_gapiObject



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

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