Class: Cumulus::S3::WebsiteConfig
- Inherits:
-
Object
- Object
- Cumulus::S3::WebsiteConfig
- Defined in:
- lib/s3/models/WebsiteConfig.rb
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#redirect ⇒ Object
readonly
Returns the value of attribute redirect.
Instance Method Summary collapse
-
#!=(other) ⇒ Object
Public: Check if this WebsiteConfig is not equal to the other object.
-
#==(other) ⇒ Object
Public: Check WebsiteConfig equality with other objects.
-
#initialize(json = nil) ⇒ WebsiteConfig
constructor
Public: Constructor.
-
#populate!(aws) ⇒ Object
Public: Populate this WebsiteConfig with the values in an AWS WebsiteConfiguration object.
-
#to_aws ⇒ Object
Public: Produce a hash that is compatible with AWS website configuration.
-
#to_h ⇒ Object
Public: Converts this WebsiteConfig to a hash that matches Cumulus configuration.
- #to_s ⇒ Object
Constructor Details
#initialize(json = nil) ⇒ WebsiteConfig
Public: Constructor
json - a hash representing the JSON configuration, expects to be handed
the 'website' node of S3 configuration.
12 13 14 15 16 17 18 |
# File 'lib/s3/models/WebsiteConfig.rb', line 12 def initialize(json = nil) if json @redirect = json["redirect"] @index = json["index"] @error = json["error"] end end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
4 5 6 |
# File 'lib/s3/models/WebsiteConfig.rb', line 4 def error @error end |
#index ⇒ Object (readonly)
Returns the value of attribute index.
5 6 7 |
# File 'lib/s3/models/WebsiteConfig.rb', line 5 def index @index end |
#redirect ⇒ Object (readonly)
Returns the value of attribute redirect.
6 7 8 |
# File 'lib/s3/models/WebsiteConfig.rb', line 6 def redirect @redirect end |
Instance Method Details
#!=(other) ⇒ Object
Public: Check if this WebsiteConfig is not equal to the other object
other - the other object to check
Returns whether this WebsiteConfig is not equal to ‘other`
90 91 92 |
# File 'lib/s3/models/WebsiteConfig.rb', line 90 def !=(other) !(self == other) end |
#==(other) ⇒ Object
Public: Check WebsiteConfig equality with other objects
other - the other object to check
Returns whether this WebsiteConfig is equal to ‘other`
74 75 76 77 78 79 80 81 82 83 |
# File 'lib/s3/models/WebsiteConfig.rb', line 74 def ==(other) if !other.is_a? WebsiteConfig or @redirect != other.redirect or @index != other.index or @error != other.error false else true end end |
#populate!(aws) ⇒ Object
Public: Populate this WebsiteConfig with the values in an AWS WebsiteConfiguration object.
aws - the aws object to populate from
24 25 26 27 28 |
# File 'lib/s3/models/WebsiteConfig.rb', line 24 def populate!(aws) @index = aws.safe_index @error = aws.safe_error @redirect = aws.safe_redirection end |
#to_aws ⇒ Object
Public: Produce a hash that is compatible with AWS website configuration.
Returns the website configuration in AWS format
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/s3/models/WebsiteConfig.rb', line 33 def to_aws if @index { error_document: { key: @error }, index_document: { suffix: @index }, } else { redirect_all_requests_to: { host_name: if @redirect and @redirect.include?("://") @redirect.split("://")[1] else @redirect end, protocol: if @redirect and @redirect.include?("://") then @redirect.split("://")[0] end } } end end |
#to_h ⇒ Object
Public: Converts this WebsiteConfig to a hash that matches Cumulus configuration.
Returns the hash
61 62 63 64 65 66 67 |
# File 'lib/s3/models/WebsiteConfig.rb', line 61 def to_h { error: @error, index: @index, redirect: @redirect, }.reject { |k, v| v.nil? } end |
#to_s ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/s3/models/WebsiteConfig.rb', line 94 def to_s if @redirect "Redirect all traffic to #{@redirect}" elsif @index if @error "Index document: #{@index}, Error document: #{@error}" else "Index document: #{@index}" end end end |