class APIGatewayDSL::Mapping
Constants
- DEFAULT_SOURCE
- TYPES
Maps Swagger parameter types to API Gateway parameter types
Public Class Methods
new(destination, direction, type, name, source)
click to toggle source
# File lib/api_gateway_dsl/mapping.rb, line 16 def initialize(destination, direction, type, name, source) @destination = destination @direction = direction @type = type @name = name @source = source end
Public Instance Methods
as_json()
click to toggle source
# File lib/api_gateway_dsl/mapping.rb, line 28 def as_json case @source when ::NilClass flatten(default_source => { @direction => { type => @name } }) when ::Symbol flatten(default_source => { @direction => { type => @source } }) when ::Hash flatten(@source) else "'#{@source}'" end end
key()
click to toggle source
# File lib/api_gateway_dsl/mapping.rb, line 24 def key "#{@destination}.#{@direction}.#{type}.#{@name}" end
response_header()
click to toggle source
# File lib/api_gateway_dsl/mapping.rb, line 41 def response_header ResponseHeader.new(@name) end
Private Instance Methods
default_source()
click to toggle source
# File lib/api_gateway_dsl/mapping.rb, line 51 def default_source DEFAULT_SOURCE[@destination] end
flatten(object)
click to toggle source
# File lib/api_gateway_dsl/mapping.rb, line 55 def flatten(object) case object when ::Hash key = object.keys.first "#{key}.#{flatten(object[key])}" else object end end
type()
click to toggle source
# File lib/api_gateway_dsl/mapping.rb, line 47 def type TYPES[@type] end