Class: Rapid::Server::Inspector
- Inherits:
-
Object
- Object
- Rapid::Server::Inspector
- Extended by:
- Forwardable
- Defined in:
- lib/ury_rapid/server/inspector.rb
Overview
An instance of the API Inspector
The API Inspector is Rapid's HTML output. It allows the API space to be navigated and interacted with in a basic way.
Because the API inspector needs more information about the model than its flat representation, the Inspector object is used to hold the extra state.
Instance Attribute Summary collapse
-
#inner ⇒ Object
readonly
Returns the value of attribute inner.
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
Instance Method Summary collapse
-
#initialize(request, target, privilege_set, inner = false) ⇒ Inspector
constructor
Initialises an instance of the API Inspector.
-
#inspect_child(id) ⇒ Object
Creates a new Inspector inspecting one of target's children.
- #resource_general_type ⇒ Object
-
#resource_type ⇒ Object
Retrieves the type of the target.
- #title ⇒ Object
Constructor Details
#initialize(request, target, privilege_set, inner = false) ⇒ Inspector
Initialises an instance of the API Inspector
24 25 26 27 28 29 30 |
# File 'lib/ury_rapid/server/inspector.rb', line 24 def initialize(request, target, privilege_set, inner = false) @request = request @target = target @resource = target.get(privilege_set) @inner = inner @privilege_set = privilege_set end |
Instance Attribute Details
#inner ⇒ Object (readonly)
Returns the value of attribute inner
14 15 16 |
# File 'lib/ury_rapid/server/inspector.rb', line 14 def inner @inner end |
#resource ⇒ Object (readonly)
Returns the value of attribute resource
36 37 38 |
# File 'lib/ury_rapid/server/inspector.rb', line 36 def resource @resource end |
Instance Method Details
#inspect_child(id) ⇒ Object
Creates a new Inspector inspecting one of target's children
52 53 54 |
# File 'lib/ury_rapid/server/inspector.rb', line 52 def inspect_child(id) Inspector.new(@request, @target.get_child(id), @privilege_set, true) end |
#resource_general_type ⇒ Object
43 44 45 |
# File 'lib/ury_rapid/server/inspector.rb', line 43 def resource_general_type @target.class.name.demodulize.underscore.intern end |
#resource_type ⇒ Object
Retrieves the type of the target
39 40 41 |
# File 'lib/ury_rapid/server/inspector.rb', line 39 def resource_type json? ? :json : @target.handler_target end |
#title ⇒ Object
32 33 34 |
# File 'lib/ury_rapid/server/inspector.rb', line 32 def title @inner ? resource_id : resource_url end |