Class: Storyblok::Links
- Inherits:
-
Object
- Object
- Storyblok::Links
- Defined in:
- lib/storyblok/links.rb
Instance Method Summary collapse
- #as_tree ⇒ Object
-
#initialize(response_obj) ⇒ Links
constructor
A new instance of Links.
Constructor Details
#initialize(response_obj) ⇒ Links
Returns a new instance of Links.
3 4 5 |
# File 'lib/storyblok/links.rb', line 3 def initialize(response_obj) @links = response_obj["data"]["links"] end |
Instance Method Details
#as_tree ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/storyblok/links.rb', line 7 def as_tree tree = {} @links.each do |key, item| if tree[item["parent_id"]].nil? tree[item["parent_id"]] = [] end tree[item["parent_id"]] << item end generate_tree(0, tree) end |