Class: Seahorse::Model::Shapes::Structure

Inherits:
Shape
  • Object
show all
Defined in:
aws-sdk-core/lib/seahorse/model/shapes.rb

Instance Attribute Summary collapse

Attributes inherited from Shape

#definition, #documentation, #location, #location_name, #name, #shape_map, #type

Instance Method Summary collapse

Methods inherited from Shape

#metadata, new

Constructor Details

#initialize(definition, options = {}) ⇒ Structure

Returns a new instance of Structure


202
203
204
205
206
207
208
209
210
# File 'aws-sdk-core/lib/seahorse/model/shapes.rb', line 202

def initialize(definition, options = {})
  super
  @members = {}
  @member_refs = {}
  @member_names = {}
  compute_member_names
  compute_required_member_names
  @member_names = @member_names.values
end

Instance Attribute Details

#member_namesArray<Symbol> (readonly)

Returns a list of members names.

Returns:

  • (Array<Symbol>)

    Returns a list of members names.


213
214
215
# File 'aws-sdk-core/lib/seahorse/model/shapes.rb', line 213

def member_names
  @member_names
end

#payloadString? (readonly)

Returns the name of the payload member if set.

Returns:

  • (String, nil)

    Returns the name of the payload member if set.


219
220
221
# File 'aws-sdk-core/lib/seahorse/model/shapes.rb', line 219

def payload
  @payload
end

#requiredArray<Symbol> (readonly)

Returns a list of required members names.

Returns:

  • (Array<Symbol>)

    Returns a list of required members names.


216
217
218
# File 'aws-sdk-core/lib/seahorse/model/shapes.rb', line 216

def required
  @required
end

Instance Method Details

#member(name) ⇒ Shape

Parameters:

  • name (Symbol)

Returns:


232
233
234
235
236
237
238
# File 'aws-sdk-core/lib/seahorse/model/shapes.rb', line 232

def member(name)
  if ref = @member_refs[name.to_sym]
    @members[name] ||= shape_for(ref)
  else
    raise ArgumentError, "no such member :#{name}"
  end
end

#member?(name) ⇒ Boolean

Returns true if this structure has a member with the given name.

Parameters:

  • name (Symbol)

Returns:

  • (Boolean)

    Returns true if this structure has a member with the given name.


243
244
245
# File 'aws-sdk-core/lib/seahorse/model/shapes.rb', line 243

def member?(name)
  @member_refs.key?(name.to_sym)
end

#member_by_location_name(location_name) ⇒ Array<Symbol,Shape>?

Searches the structure members for a shape with the given serialized name.

If found, the shape will be returned with its symbolized member name.

If no shape is found with the given serialized name, then nil is returned.

Examples:


name, shape = structure.member_by_location_name('SerializedName')
name #=> :member_name
shape #=> instance of Seahorse::Model::Shapes::Shape

Parameters:

Returns:

  • (Array<Symbol,Shape>, nil)

274
275
276
277
# File 'aws-sdk-core/lib/seahorse/model/shapes.rb', line 274

def member_by_location_name(location_name)
  @by_location_name ||= index_members_by_location_name
  @by_location_name[location_name]
end

#membersEnumerable<Symbol,Shape>

Returns an enumerator that yields member names and shapes.

Returns:

  • (Enumerable<Symbol,Shape>)

    Returns an enumerator that yields member names and shapes.


249
250
251
252
253
254
255
# File 'aws-sdk-core/lib/seahorse/model/shapes.rb', line 249

def members
  Enumerator.new do |y|
    member_names.map do |member_name|
      y.yield(member_name, member(member_name))
    end
  end
end

#payload_memberShape?

Returns:


222
223
224
225
226
227
228
# File 'aws-sdk-core/lib/seahorse/model/shapes.rb', line 222

def payload_member
  if payload
    @payload_member ||= member(payload)
  else
    nil
  end
end