Class: RoadForest::Augment::LazyResource
- Inherits:
-
Object
- Object
- RoadForest::Augment::LazyResource
- Defined in:
- lib/roadforest/augment/augmentation.rb
Instance Attribute Summary collapse
-
#router ⇒ Object
Returns the value of attribute router.
-
#uri ⇒ Object
Returns the value of attribute uri.
Instance Method Summary collapse
-
#initialize(uri, router) ⇒ LazyResource
constructor
A new instance of LazyResource.
- #request ⇒ Object
- #resource ⇒ Object
- #response ⇒ Object
- #route ⇒ Object
- #type_list ⇒ Object
Constructor Details
#initialize(uri, router) ⇒ LazyResource
Returns a new instance of LazyResource.
45 46 47 48 |
# File 'lib/roadforest/augment/augmentation.rb', line 45 def initialize(uri, router) @uri = uri @router = router end |
Instance Attribute Details
#router ⇒ Object
Returns the value of attribute router.
50 51 52 |
# File 'lib/roadforest/augment/augmentation.rb', line 50 def router @router end |
#uri ⇒ Object
Returns the value of attribute uri.
50 51 52 |
# File 'lib/roadforest/augment/augmentation.rb', line 50 def uri @uri end |
Instance Method Details
#request ⇒ Object
52 53 54 |
# File 'lib/roadforest/augment/augmentation.rb', line 52 def request @request ||= Webmachine::Request.new("GET", uri, {}, nil) end |
#resource ⇒ Object
64 65 66 |
# File 'lib/roadforest/augment/augmentation.rb', line 64 def resource @resource ||= router.find_resource(request, response) end |
#response ⇒ Object
56 57 58 |
# File 'lib/roadforest/augment/augmentation.rb', line 56 def response @response ||= Webmachine::Response.new end |
#route ⇒ Object
60 61 62 |
# File 'lib/roadforest/augment/augmentation.rb', line 60 def route @route ||= router.find_route(request) end |
#type_list ⇒ Object
68 69 70 71 72 73 |
# File 'lib/roadforest/augment/augmentation.rb', line 68 def type_list @type_list ||= resource.content_types_provided.inject(ContentHandling::MediaTypeList.new) do |list, (type, _)| list.add_header_val(type) end end |