Class: ActiveSwagger::Params

Inherits:
Object
  • Object
show all
Defined in:
lib/active_swagger/params.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(properties) ⇒ Params

Returns a new instance of Params.



7
8
9
# File 'lib/active_swagger/params.rb', line 7

def initialize(properties)
  @properties = properties
end

Instance Attribute Details

#propertiesObject

Returns the value of attribute properties.



5
6
7
# File 'lib/active_swagger/params.rb', line 5

def properties
  @properties
end

Instance Method Details

#mapping(key, value) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/active_swagger/params.rb', line 11

def mapping(key, value)
  case value[:type]
  when :array
    { key => [] }
  when :object
    { key => {} }
  else
    key
  end
end

#to_strong_paramsObject



22
23
24
25
26
27
28
# File 'lib/active_swagger/params.rb', line 22

def to_strong_params
  params = []
  properties.each_pair do |key, value|
    params.push(mapping(key, value))
  end
  params
end