Module: Seahorse::Model::Shapes

Defined in:
aws-sdk-core/lib/seahorse/model/shapes.rb

Defined Under Namespace

Classes: Blob, Boolean, Byte, Character, Double, Float, Integer, List, Long, Map, Shape, String, Structure, Timestamp

Class Method Summary collapse

Class Method Details

.register(type, shape_class) ⇒ void

This method returns an undefined value.

Registers a shape by type.

Shapes.register('structure', Shapes::StructureShape)

Shapes.type('structure')
#=> #<Shapes::StructureShape>

Parameters:

Raises:

  • (ArgumentError)

    Raises an error if the given type or shape class have already been registered.


23
24
25
26
# File 'aws-sdk-core/lib/seahorse/model/shapes.rb', line 23

def register(type, shape_class)
  shape_class.type = type
  @types[type] = shape_class
end

.shape_class(type) ⇒ Class<Shape>

Given a type, this method returned the registered shape class.

Parameters:

Returns:

Raises:

  • (ArgumentError)

    Raises an ArgumentError if there is no shape class registered with the given type.


33
34
35
36
37
38
39
# File 'aws-sdk-core/lib/seahorse/model/shapes.rb', line 33

def shape_class(type)
  if @types.key?(type)
    @types[type]
  else
    raise ArgumentError, "unregisterd type `#{type}'"
  end
end

.typesEnumerator

Returns an enumerator that yields registered type names and shape classes.

Seahorse::Model::Shapes.types.each do |type, shape_class| puts "%s => %s" % [type, shape_class.name] end

Returns:

  • (Enumerator)

    Returns an enumerable object that yields registered type names and shape classes.


50
51
52
53
54
55
56
# File 'aws-sdk-core/lib/seahorse/model/shapes.rb', line 50

def types
  Enumerator.new do |y|
    @types.each do |name, shape_class|
      y.yield(name, shape_class)
    end
  end
end