Class: TryApi::Project

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#id, typesafe_accessor

Class Method Details

.parse(hash) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/models/try_api/project.rb', line 10

def parse(hash)
  instance = self.new
  instance.name = hash[:project_name]
  instance.host = hash[:host]
  instance.port = hash[:port]
  instance.api_prefix = hash[:api_prefix]
  instance.menu_items = []
  hash[:menu_items].each do |category|
    instance.menu_items << TryApi::MenuItem.parse(hash: category, project: instance)
  end
  instance
end

Instance Method Details

#endpointObject



28
29
30
# File 'app/models/try_api/project.rb', line 28

def endpoint
  "#{ host }#{ port.blank? ? '' : (':' + port.to_s) }"
end

#to_jsonObject



24
25
26
# File 'app/models/try_api/project.rb', line 24

def to_json
  super.merge endpoint: endpoint
end