Class: Seahorse::Model::Shapes::Shape

Inherits:
Object
  • Object
show all
Defined in:
lib/seahorse/model/shapes.rb

Direct Known Subclasses

Blob, Boolean, Float, Integer, List, Map, String, Structure, Timestamp

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Shape.

Parameters:

  • definition (Hash)
  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :shape_map (ShapeMap) — default: nil


64
65
66
67
68
69
70
71
72
# File 'lib/seahorse/model/shapes.rb', line 64

def initialize(definition, options = {})
  definition['type'] ||= self.class.type
  @name = definition['shape']
  @definition = definition
  @type = definition['type']
  @location = definition['location'] || 'body'
  @location_name = definition['locationName']
  @shape_map = options[:shape_map] || ShapeMap.new
end

Class Attribute Details

.typeString

Returns:



145
146
147
# File 'lib/seahorse/model/shapes.rb', line 145

def type
  @type
end

Instance Attribute Details

#definitionHash (readonly)

Returns:

  • (Hash)


78
79
80
# File 'lib/seahorse/model/shapes.rb', line 78

def definition
  @definition
end

#documentationString? (readonly)

Returns:



97
98
99
# File 'lib/seahorse/model/shapes.rb', line 97

def documentation
  @documentation
end

#locationString (readonly)

Returns one of ‘body’, ‘uri’, ‘headers’, ‘status_code’

Returns:

  • (String)

    Returns one of ‘body’, ‘uri’, ‘headers’, ‘status_code’



84
85
86
# File 'lib/seahorse/model/shapes.rb', line 84

def location
  @location
end

#location_nameString? (readonly)

Returns Typically only set for shapes that are structure members. Serialized names are typically set on the shape references, not on the shape definition.

Returns:

  • (String, nil)

    Typically only set for shapes that are structure members. Serialized names are typically set on the shape references, not on the shape definition.



89
90
91
# File 'lib/seahorse/model/shapes.rb', line 89

def location_name
  @location_name
end

#nameString (readonly)

Returns:



75
76
77
# File 'lib/seahorse/model/shapes.rb', line 75

def name
  @name
end

#shape_mapShapeMap (readonly)

Returns:



94
95
96
# File 'lib/seahorse/model/shapes.rb', line 94

def shape_map
  @shape_map
end

#typeString (readonly)

Returns The type name for this shape.

Returns:

  • (String)

    The type name for this shape.



81
82
83
# File 'lib/seahorse/model/shapes.rb', line 81

def type
  @type
end

Class Method Details

.new(definition = {}, options = {}) ⇒ Shape

Constructs and returns a new shape object. You must specify the shape type using the “type” option or you must construct the shape using the appropriate subclass of ‘Shape`.

Examples:

Constructing a new shape


shape = Seahorse::Model::Shapes::Shape.new("type" => "structure")

shape.class
#=> Seahorse::Model::Shapes::Structure

shape.definition
#=> { "type" => "structure" }

Constructing a new shape using the shape class


shape = Seahorse::Model::Shapes::String.new
shape.definition
#=> { "type" => "string" }

Parameters:

  • definition (Hash) (defaults to: {})
  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

Returns:



170
171
172
173
174
175
176
# File 'lib/seahorse/model/shapes.rb', line 170

def new(definition = {}, options = {})
  if self == Shape
    from_type(definition, options)
  else
    super(apply_type(definition), options)
  end
end

Instance Method Details

#inspectString

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:



109
110
111
# File 'lib/seahorse/model/shapes.rb', line 109

def inspect
  "#<#{self.class.name}>"
end

#metadata(key) ⇒ Object?

Parameters:

Returns:

  • (Object, nil)


103
104
105
# File 'lib/seahorse/model/shapes.rb', line 103

def (key)
  @definition[key.to_s]
end

#with(options) ⇒ 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.



114
115
116
# File 'lib/seahorse/model/shapes.rb', line 114

def with(options)
  self.class.new(@definition.merge(options), shape_map: shape_map)
end