Class: Cloudfront::Helpers::S3Origin

Inherits:
Object
  • Object
show all
Includes:
Utils::ConfigurationChecker, Utils::XmlSerializer
Defined in:
lib/cloudfront/helpers/s3_origin.rb

Instance Attribute Summary collapse

Attributes included from Utils::ConfigurationChecker

#error_messages

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Utils::XmlSerializer

#to_xml

Methods included from Utils::ConfigurationChecker

#check_configuration, #valid?

Constructor Details

#initialize(&block) ⇒ S3Origin

Returns a new instance of S3Origin.



12
13
14
15
# File 'lib/cloudfront/helpers/s3_origin.rb', line 12

def initialize(&block)
  #set value from block
  instance_eval &block if block_given?
end

Instance Attribute Details

#domain_nameObject

Returns the value of attribute domain_name.



9
10
11
# File 'lib/cloudfront/helpers/s3_origin.rb', line 9

def domain_name
  @domain_name
end

#origin_access_identityObject

Returns the value of attribute origin_access_identity.



9
10
11
# File 'lib/cloudfront/helpers/s3_origin.rb', line 9

def origin_access_identity
  @origin_access_identity
end

Class Method Details

.from_hash(hash) ⇒ Object

{

"S3Origin" => {
  "DomainName" => "CloudFront domain name assigned to the distribution",
  "OriginAccessIdentity" => "origin-access-identity/cloudfront/ID"
}

}



28
29
30
31
32
33
34
# File 'lib/cloudfront/helpers/s3_origin.rb', line 28

def self.from_hash(hash)
  hash = hash["S3Origin"] || hash
  self.new do
    self.domain_name = hash["DomainName"]
    self.origin_access_identity = hash["OriginAccessIdentity"]
  end
end

Instance Method Details

#build_xml(xml) ⇒ Object

The origin class container

<S3Origin>
   <DomainName>CloudFront domain name assigned to the distribution</DNSName>
   <OriginAccessIdentity>origin-access-identity/cloudfront/ID</OriginAccessIdentity>
</S3Origin>


41
42
43
44
45
46
47
# File 'lib/cloudfront/helpers/s3_origin.rb', line 41

def build_xml(xml)
  check_configuration
  xml.S3Origin {
    xml.DomainName @domain_name unless @domain_name.nil?
    xml.OriginAccessIdentity @origin_access_identity
  }
end

#validateObject



17
18
19
20
# File 'lib/cloudfront/helpers/s3_origin.rb', line 17

def validate
  error_messages.push "domain_name can't be null" if @domain_name.nil?
  error_messages.push "origin_access_identity can't be null" if @origin_access_identity.nil?
end