Class: TryApi::MenuItem

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

Class Method Summary collapse

Methods inherited from Base

#id, #to_json, typesafe_accessor

Class Method Details

.parse(hash:, project:) ⇒ Object



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

def parse(hash:, project:)
  instance = self.new
  instance.project = project
  instance.title = hash[:title]
  instance.html = hash[:html]
  instance.description = hash[:description]
  instance.methods = []
  unless hash[:methods].blank?
    hash[:methods].each do |second_level_meny_item|
      instance.methods << TryApi::Method.parse(project: instance.project, hash: second_level_meny_item)
    end
  end
  instance
end