class Seahorse::Model::Shapes::Shape

def apply_type(definition)

def apply_type(definition)
  case definition['type']
  when type then definition
  when nil then { 'type' => type }.merge(definition)
  else raise ArgumentError, "expected 'type' to be `#{type}'"
  end
end

def documentation

Returns:
  • (String, nil) -
def documentation
  @definition['documentation']
end

def from_type(definition, options)

def from_type(definition, options)
  if type = definition['type']
    Shapes.shape_class(type).new(definition, options)
  else
    raise ArgumentError, 'must specify "type" in the definition'
  end
end

def initialize(definition, options = {})

Options Hash: (**options)
  • :shape_map (ShapeMap) --

Parameters:
  • definition (Hash) --
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

def inspect

Returns:
  • (String) -

Other tags:
    Api: - private
def inspect
  "#<#{self.class.name}>"
end

def metadata(key)

Returns:
  • (Object, nil) -

Parameters:
  • key (String) --
def metadata(key)
  @definition[key.to_s]
end

def new(definition = {}, options = {})

Returns:
  • (Shape) -

Options Hash: (**options)
  • :shape_map (ShapeMap) --

Parameters:
  • definition (Hash) --

Other tags:
    Example: Constructing a new shape using the shape class -
    Example: Constructing a new shape -
def new(definition = {}, options = {})
  if self == Shape
    from_type(definition, options)
  else
    super(apply_type(definition), options)
  end
end

def shape_at(key)

def shape_at(key)
  if @definition[key]
    shape_for(@definition[key])
  else
    raise ArgumentError, "expected shape definition at #{key.inspect}"
  end
end

def shape_for(reference)

def shape_for(reference)
  if reference.key?('shape')
    # shape ref given, e.g. { "shape" => "ShapeName" },
    # use the shape map to resolve this reference
    @shape_map.shape(reference)
  else
    Shape.new(reference, shape_map: @shape_map)
  end
end

def underscore(string)

def underscore(string)
  Util.underscore(string)
end

def with(options)

Other tags:
    Api: - private
def with(options)
  self.class.new(@definition.merge(options), shape_map: shape_map)
end