Module: Rapid::Server::Helpers::Inspector

Defined in:
lib/ury_rapid/server/helpers/inspector.rb

Overview

Sinatra helpers for the API Inspector

Instance Method Summary collapse

Instance Method Details

#child(inspector, id) ⇒ Object


8
9
10
11
# File 'lib/ury_rapid/server/helpers/inspector.rb', line 8

def child(inspector, id)
  insp = inspector.inspect_child(id)
  inspector_haml(insp)
end

#inspector_haml(inspector) ⇒ Object

Renders an API Inspector instance using HAML.


24
25
26
27
28
29
30
31
32
33
# File 'lib/ury_rapid/server/helpers/inspector.rb', line 24

def inspector_haml(inspector)
  render = ->(type) { haml(type, locals: { inspector: inspector }) }
  begin
    render.call(inspector.resource_type)
  rescue Errno::ENOENT
    # There was no template for the resource type, so try something
    # more general.
    render.call(inspector.resource_general_type)
  end
end

13
14
15
16
17
18
19
20
21
# File 'lib/ury_rapid/server/helpers/inspector.rb', line 13

def navigation(inspector)
  haml(
    :in_out_links,
    locals: {
      resource_url: inspector.resource_url,
      inner: inspector.inner
    }
  )
end