Module: Aws::Structure Private
- Included in:
- EmptyStructure, Aws::STS::Types::AssumeRoleRequest, Aws::STS::Types::AssumeRoleResponse, Aws::STS::Types::AssumeRoleWithSAMLRequest, Aws::STS::Types::AssumeRoleWithSAMLResponse, Aws::STS::Types::AssumeRoleWithWebIdentityRequest, Aws::STS::Types::AssumeRoleWithWebIdentityResponse, Aws::STS::Types::AssumedRoleUser, Aws::STS::Types::Credentials, Aws::STS::Types::DecodeAuthorizationMessageRequest, Aws::STS::Types::DecodeAuthorizationMessageResponse, Aws::STS::Types::FederatedUser, Aws::STS::Types::GetCallerIdentityResponse, Aws::STS::Types::GetFederationTokenRequest, Aws::STS::Types::GetFederationTokenResponse, Aws::STS::Types::GetSessionTokenRequest, Aws::STS::Types::GetSessionTokenResponse
- Defined in:
- lib/aws-sdk-core/structure.rb
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Class Method Summary collapse
- .included(base_class) ⇒ Object private
- .new(*args) ⇒ Object private
Instance Method Summary collapse
-
#empty? ⇒ Boolean
private
Returns
trueif all of the member values arenil. - #initialize(values = {}) ⇒ Object private
-
#key?(member_name) ⇒ Boolean
private
Returns
trueif this structure has a value set for the given member. -
#to_h(obj = self) ⇒ Hash
(also: #to_hash)
private
Deeply converts the Structure into a hash.
Class Method Details
.included(base_class) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
62 63 64 |
# File 'lib/aws-sdk-core/structure.rb', line 62 def self.included(base_class) base_class.send(:undef_method, :each) end |
.new(*args) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
51 52 53 54 55 56 57 58 59 |
# File 'lib/aws-sdk-core/structure.rb', line 51 def new(*args) if args.empty? Aws::EmptyStructure else struct = Struct.new(*args) struct.send(:include, Aws::Structure) struct end end |
Instance Method Details
#empty? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns true if all of the member values are nil.
18 19 20 |
# File 'lib/aws-sdk-core/structure.rb', line 18 def empty? values.compact == [] end |
#initialize(values = {}) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
5 6 7 8 9 |
# File 'lib/aws-sdk-core/structure.rb', line 5 def initialize(values = {}) values.each do |k, v| self[k] = v end end |
#key?(member_name) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns true if this structure has a value set for the given member.
13 14 15 |
# File 'lib/aws-sdk-core/structure.rb', line 13 def key?(member_name) !self[member_name].nil? end |
#to_h(obj = self) ⇒ Hash Also known as: to_hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Deeply converts the Structure into a hash. Structure members that are nil are omitted from the resultant hash.
You can call #orig_to_h to get vanilla #to_h behavior as defined in stdlib Struct.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/aws-sdk-core/structure.rb', line 29 def to_h(obj = self) case obj when Struct obj.members.each.with_object({}) do |member, hash| value = obj[member] hash[member] = to_hash(value) unless value.nil? end when Hash obj.each.with_object({}) do |(key, value), hash| hash[key] = to_hash(value) end when Array obj.collect { |value| to_hash(value) } else obj end end |