@return [Array<Symbol>] Returns a list of members names.
@return [String, nil] Returns the name of the payload member if set.
@return [Array<Symbol>] Returns a list of required members names.
# File 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
@param [Symbol] name @return [Shape]
# File 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
@param [Symbol] name @return [Boolean] Returns `true` if this structure has a member with
the given name.
# File lib/seahorse/model/shapes.rb, line 243 def member?(name) @member_refs.key?(name.to_sym) end
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.
@example
name, shape = structure.member_by_location_name('SerializedName') name #=> :member_name shape #=> instance of Seahorse::Model::Shapes::Shape
@param [String] location_name @return [Array<Symbol,Shape>, nil]
# File 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
@return [Enumerable<Symbol,Shape>] Returns an enumerator that yields
member names and shapes.
# File 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
@return [Shape, nil]
# File lib/seahorse/model/shapes.rb, line 222 def payload_member if payload @payload_member ||= member(payload) else nil end end
# File lib/seahorse/model/shapes.rb, line 287 def compute_member_names (definition['members'] || {}).each do |orig_name,ref| name = underscore(orig_name).to_sym if ref['location'] == 'headers' @member_refs[name] = ref else @member_refs[name] = { 'locationName' => orig_name }.merge(ref) end @member_names[orig_name] = name end @payload = @member_names[definition['payload']] if definition['payload'] end
# File lib/seahorse/model/shapes.rb, line 300 def compute_required_member_names @required = (definition['required'] || []).map do |orig_name| @member_names[orig_name] end end
# File lib/seahorse/model/shapes.rb, line 281 def index_members_by_location_name members.each.with_object({}) do |(name, shape), hash| hash[shape.location_name] = [name, shape] end end