Class: RoadForest::Application::ResourceAdapter
- Inherits:
-
Object
- Object
- RoadForest::Application::ResourceAdapter
- Defined in:
- lib/roadforest/application/route-adapter.rb
Overview
Embedded in WebMachine’s Routes to compose the object structure at need
Instance Attribute Summary collapse
-
#content_engine ⇒ Object
Returns the value of attribute content_engine.
-
#interface_builder ⇒ Object
Returns the value of attribute interface_builder.
-
#resource_builder ⇒ Object
Returns the value of attribute resource_builder.
-
#route_name ⇒ Object
Returns the value of attribute route_name.
-
#router ⇒ Object
Returns the value of attribute router.
-
#services ⇒ Object
Returns the value of attribute services.
-
#trace ⇒ Object
Returns the value of attribute trace.
Instance Method Summary collapse
- #<(klass) ⇒ Object
- #build_interface(params) ⇒ Object
- #interface_class ⇒ Object
- #new(request, response) ⇒ Object
- #trace? ⇒ Boolean
Instance Attribute Details
#content_engine ⇒ Object
Returns the value of attribute content_engine.
5 6 7 |
# File 'lib/roadforest/application/route-adapter.rb', line 5 def content_engine @content_engine end |
#interface_builder ⇒ Object
Returns the value of attribute interface_builder.
5 6 7 |
# File 'lib/roadforest/application/route-adapter.rb', line 5 def interface_builder @interface_builder end |
#resource_builder ⇒ Object
Returns the value of attribute resource_builder.
5 6 7 |
# File 'lib/roadforest/application/route-adapter.rb', line 5 def resource_builder @resource_builder end |
#route_name ⇒ Object
Returns the value of attribute route_name.
5 6 7 |
# File 'lib/roadforest/application/route-adapter.rb', line 5 def route_name @route_name end |
#router ⇒ Object
Returns the value of attribute router.
5 6 7 |
# File 'lib/roadforest/application/route-adapter.rb', line 5 def router @router end |
#services ⇒ Object
Returns the value of attribute services.
5 6 7 |
# File 'lib/roadforest/application/route-adapter.rb', line 5 def services @services end |
#trace ⇒ Object
Returns the value of attribute trace.
5 6 7 |
# File 'lib/roadforest/application/route-adapter.rb', line 5 def trace @trace end |
Instance Method Details
#<(klass) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/roadforest/application/route-adapter.rb', line 7 def <(klass) if klass <= Webmachine::Resource return true else return false end end |
#build_interface(params) ⇒ Object
23 24 25 |
# File 'lib/roadforest/application/route-adapter.rb', line 23 def build_interface(params) interface_builder.call(route_name, params, router.path_provider(route_name), router.services) end |
#interface_class ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/roadforest/application/route-adapter.rb', line 27 def interface_class if interface_builder.respond_to? :interface_class interface_builder.interface_class else nil end end |
#new(request, response) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/roadforest/application/route-adapter.rb', line 15 def new(request, response) resource = resource_builder.call(request, response) resource.interface = build_interface(resource.params) resource.content_engine = content_engine || router.default_content_engine resource.trace = trace? resource end |
#trace? ⇒ Boolean
35 36 37 38 39 40 41 |
# File 'lib/roadforest/application/route-adapter.rb', line 35 def trace? if @trace.nil? router.trace_by_default else !!@trace end end |