module Aws::Structure

@api private

Public Class Methods

included(base_class) click to toggle source

@api private

# File lib/aws-sdk-core/structure.rb, line 70
def self.included(base_class)
  base_class.send(:undef_method, :each)
end
new(values = {}) click to toggle source
# File lib/aws-sdk-core/structure.rb, line 7
def initialize(values = {})
  values.each do |k, v|
    self[k] = v
  end
end
new(*args) click to toggle source

@api private

# File lib/aws-sdk-core/structure.rb, line 59
def new(*args)
  if args.empty?
    Aws::EmptyStructure
  else
    struct = Struct.new(*args)
    struct.send(:include, Aws::Structure)
    struct
  end
end

Public Instance Methods

empty?() click to toggle source

@return [Boolean] Returns ‘true` if all of the member values are `nil`.

# File lib/aws-sdk-core/structure.rb, line 20
def empty?
  values.compact == []
end
key?(member_name) click to toggle source

@return [Boolean] Returns ‘true` if this structure has a value

set for the given member.
# File lib/aws-sdk-core/structure.rb, line 15
def key?(member_name)
  !self[member_name].nil?
end
to_h(obj = self, options = {}) click to toggle source

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.

@return [Hash]

# File lib/aws-sdk-core/structure.rb, line 31
def to_h(obj = self, options = {})
  case obj
  when Struct
    obj.each_pair.with_object({}) do |(member, value), hash|
      member = member.to_s if options[:as_json]
      hash[member] = to_hash(value, options) unless value.nil?
    end
  when Hash
    obj.each.with_object({}) do |(key, value), hash|
      key = key.to_s if options[:as_json]
      hash[key] = to_hash(value, options)
    end
  when Array
    obj.collect { |value| to_hash(value, options) }
  else
    obj
  end
end
Also aliased as: to_hash
to_hash(obj = self, options = {})
Alias for: to_h
to_s(obj = self) click to toggle source

Wraps the default to_s logic with filtering of sensitive parameters.

# File lib/aws-sdk-core/structure.rb, line 52
def to_s(obj = self)
  Aws::Log::ParamFilter.new.filter(obj, obj.class).to_s
end