Module: Rooftop::Nested

Defined in:
lib/rooftop/nested.rb

Instance Method Summary collapse

Instance Method Details

#ancestorsObject



4
5
6
7
8
9
10
# File 'lib/rooftop/nested.rb', line 4

def ancestors
  if respond_to?(:resource_links)
    resource_links.find_by(link_type: "#{Rooftop::ResourceLinks::CUSTOM_LINK_RELATION_BASE}/ancestors")
  else
    []
  end
end

#childrenObject



12
13
14
15
16
17
18
# File 'lib/rooftop/nested.rb', line 12

def children
  if respond_to?(:resource_links)
    resource_links.find_by(link_type: "#{Rooftop::ResourceLinks::CUSTOM_LINK_RELATION_BASE}/children")
  else
    []
  end
end

#parentObject



20
21
22
23
24
# File 'lib/rooftop/nested.rb', line 20

def parent
  if respond_to?(:resource_links)
    resource_links.find_by(link_type: "up").first
  end
end