Class: Seahorse::ApiTranslator::Shape

Inherits:
Object
  • Object
show all
Includes:
Inflector
Defined in:
lib/seahorse/api_translator/shape.rb

Direct Known Subclasses

InputShape, OutputShape

Instance Method Summary collapse

Methods included from Inflector

#inflect

Constructor Details

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

Returns a new instance of Shape.



24
25
26
27
28
29
30
31
32
# File 'lib/seahorse/api_translator/shape.rb', line 24

def initialize rules, options = {}
  @options = options
  @rules = {}
  @rules['name'] = options['name'] if options.key?('name')
  set_type(rules.delete('type'))
  rules.each_pair do |method,arg|
    send("set_#{method}", *[arg])
  end
end

Instance Method Details

#rulesObject



34
35
36
37
38
39
40
41
42
# File 'lib/seahorse/api_translator/shape.rb', line 34

def rules
  if @rules['type'] != 'blob'
    @rules
  elsif @rules['payload'] or @rules['streaming']
    @rules.merge('type' => 'binary')
  else
    @rules.merge('type' => 'base64')
  end
end

#xmlnameObject



44
45
46
47
48
49
50
# File 'lib/seahorse/api_translator/shape.rb', line 44

def xmlname
  if @rules['flattened']
    (@rules['members'] || {})['name'] || @xmlname
  else
    @xmlname
  end
end