Class: Cloudfront::Helpers::TrustedSigners
- Inherits:
-
Object
- Object
- Cloudfront::Helpers::TrustedSigners
- Includes:
- Utils::ConfigurationChecker, Utils::XmlSerializer
- Defined in:
- lib/cloudfront/helpers/trusted_signers.rb
Instance Attribute Summary collapse
-
#enabled ⇒ Object
Returns the value of attribute enabled.
-
#trusted_signers ⇒ Object
Returns the value of attribute trusted_signers.
Attributes included from Utils::ConfigurationChecker
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
A factory method that creates a TrustedSigners instance from a hash Input example hash = { “TrustedSigners” => { “Enabled” => “true | false”, “Quantity” => “number of trusted signers”, “Items” => { “AwsAccountNumber” => “self | AWS account that can create signed URLs” } } }.
Instance Method Summary collapse
-
#build_xml(xml) ⇒ Object
Output example <TrustedSigners> <Enabled>true</Enabled> <Quantity>number of trusted signers</Quantity> <Items> <AwsAccountNumber>self</AwsAccountNumber> </Items> </TrustedSigners>.
-
#initialize(&block) ⇒ TrustedSigners
constructor
A new instance of TrustedSigners.
- #validate ⇒ Object
Methods included from Utils::XmlSerializer
Methods included from Utils::ConfigurationChecker
Constructor Details
#initialize(&block) ⇒ TrustedSigners
Returns a new instance of TrustedSigners.
12 13 14 15 16 17 18 19 |
# File 'lib/cloudfront/helpers/trusted_signers.rb', line 12 def initialize(&block) #set default values @enabled = false @trusted_signers = [] #set values from block instance_eval &block if block_given? end |
Instance Attribute Details
#enabled ⇒ Object
Returns the value of attribute enabled.
9 10 11 |
# File 'lib/cloudfront/helpers/trusted_signers.rb', line 9 def enabled @enabled end |
#trusted_signers ⇒ Object
Returns the value of attribute trusted_signers.
9 10 11 |
# File 'lib/cloudfront/helpers/trusted_signers.rb', line 9 def trusted_signers @trusted_signers end |
Class Method Details
.from_hash(hash) ⇒ Object
A factory method that creates a TrustedSigners instance from a hash Input example hash = {
"TrustedSigners" => {
"Enabled" => "true | false",
"Quantity" => "number of trusted signers",
"Items" => {
"AwsAccountNumber" => "self | AWS account that can create signed URLs"
}
}
}
38 39 40 41 42 43 44 45 46 |
# File 'lib/cloudfront/helpers/trusted_signers.rb', line 38 def self.from_hash(hash) hash = hash["TrustedSigners"] || hash self.new do self.enabled = hash["Enabled"].nil? ? nil : hash["Enabled"].to_bool if (hash["Quantity"]|| "0").to_i > 0 self.trusted_signers = Array.wrap((hash["Items"]|| {})["AwsAccountNumber"]) end end end |
Instance Method Details
#build_xml(xml) ⇒ Object
Output example
<TrustedSigners>
<Enabled>true</Enabled>
<Quantity>number of trusted signers</Quantity>
<Items>
<AwsAccountNumber>self</AwsAccountNumber>
</Items>
</TrustedSigners>
56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/cloudfront/helpers/trusted_signers.rb', line 56 def build_xml(xml) check_configuration xml.TrustedSigners { xml.Enabled (@enabled || @trusted_signers.any?) xml.Quantity @trusted_signers.size if @trusted_signers.any? xml.Items { for signer in @trusted_signers xml.AwsAccountNumber signer end } end } end |