Class: TryApi::Parameter

Inherits:
Base
  • Object
show all
Defined in:
app/models/try_api/parameter.rb

Class Method Summary collapse

Methods inherited from Base

#id, #to_json, typesafe_accessor

Class Method Details

.parse(hash) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/models/try_api/parameter.rb', line 10

def parse(hash)
  instance = self.new
  instance.name = hash[:name]
  instance.type = hash[:type]
  instance.required = hash[:required]
  instance.description = hash[:description]

  instance.parameters = []
  if hash[:parameters].is_a? Array
    hash[:parameters].each do |parameter|
      instance.parameters << TryApi::Parameter.parse(parameter)
    end
  else
    #   TODO raise exception ?
  end

  instance
end