Class: RoadForest::Augment::LazyResource

Inherits:
Object
  • Object
show all
Defined in:
lib/roadforest/augment/augmentation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#routerObject

Returns the value of attribute router.



50
51
52
# File 'lib/roadforest/augment/augmentation.rb', line 50

def router
  @router
end

#uriObject

Returns the value of attribute uri.



50
51
52
# File 'lib/roadforest/augment/augmentation.rb', line 50

def uri
  @uri
end

Instance Method Details

#requestObject



52
53
54
# File 'lib/roadforest/augment/augmentation.rb', line 52

def request
  @request ||= Webmachine::Request.new("GET", uri, {}, nil)
end

#resourceObject



64
65
66
# File 'lib/roadforest/augment/augmentation.rb', line 64

def resource
  @resource ||= router.find_resource(request, response)
end

#responseObject



56
57
58
# File 'lib/roadforest/augment/augmentation.rb', line 56

def response
  @response ||= Webmachine::Response.new
end

#routeObject



60
61
62
# File 'lib/roadforest/augment/augmentation.rb', line 60

def route
  @route ||= router.find_route(request)
end

#type_listObject



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