Class: RoadForest::Interface::Application
- Inherits:
-
Object
- Object
- RoadForest::Interface::Application
- Defined in:
- lib/roadforest/interface/application.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#path_provider ⇒ Object
readonly
Returns the value of attribute path_provider.
-
#response_values ⇒ Object
readonly
Returns the value of attribute response_values.
-
#route_name ⇒ Object
readonly
Returns the value of attribute route_name.
-
#services ⇒ Object
readonly
Returns the value of attribute services.
Utility methods collapse
- #canonical_uri ⇒ Object
- #interface_for(route_name = nil, params = nil) ⇒ Object
- #my_path ⇒ Object
- #my_url ⇒ Object
- #path_for(route_name = nil, params = nil) ⇒ Object
- #pattern_for(route_name, vals = nil, extra = nil) ⇒ Object
- #url_for(route_name, params = nil) ⇒ Object
Authorization collapse
- #authentication_challenge ⇒ Object
- #authorization(request) ⇒ Object
- #required_grants(method) ⇒ Object
Instance Method Summary collapse
- #add_child(results) ⇒ Object
- #canonical_host ⇒ Object
- #create_payload ⇒ Object
- #delete ⇒ Object
-
#error_data(status) ⇒ Object
group Resource interface.
- #etag ⇒ Object
- #exists? ⇒ Boolean
- #expires ⇒ Object
-
#initialize(route_name, params, path_provider, services) ⇒ Application
constructor
A new instance of Application.
- #last_modified ⇒ Object
- #processed ⇒ Object
-
#reset ⇒ Object
XXX remove?.
- #response_data ⇒ Object
- #response_data=(data) ⇒ Object
- #response_location ⇒ Object
- #response_location=(location) ⇒ Object
- #retrieve ⇒ Object (also: #retreive)
- #update(data) ⇒ Object
- #update_payload ⇒ Object
Constructor Details
#initialize(route_name, params, path_provider, services) ⇒ Application
Returns a new instance of Application.
12 13 14 15 16 17 18 19 |
# File 'lib/roadforest/interface/application.rb', line 12 def initialize(route_name, params, path_provider, services) @route_name = route_name @params = params @path_provider = path_provider @services = services @data = nil @response_values = {} end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
20 21 22 |
# File 'lib/roadforest/interface/application.rb', line 20 def data @data end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
20 21 22 |
# File 'lib/roadforest/interface/application.rb', line 20 def params @params end |
#path_provider ⇒ Object (readonly)
Returns the value of attribute path_provider.
20 21 22 |
# File 'lib/roadforest/interface/application.rb', line 20 def path_provider @path_provider end |
#response_values ⇒ Object (readonly)
Returns the value of attribute response_values.
21 22 23 |
# File 'lib/roadforest/interface/application.rb', line 21 def response_values @response_values end |
#route_name ⇒ Object (readonly)
Returns the value of attribute route_name.
20 21 22 |
# File 'lib/roadforest/interface/application.rb', line 20 def route_name @route_name end |
#services ⇒ Object (readonly)
Returns the value of attribute services.
20 21 22 |
# File 'lib/roadforest/interface/application.rb', line 20 def services @services end |
Instance Method Details
#add_child(results) ⇒ Object
148 149 150 |
# File 'lib/roadforest/interface/application.rb', line 148 def add_child(results) raise NotImplementedError end |
#authentication_challenge ⇒ Object
73 74 75 |
# File 'lib/roadforest/interface/application.rb', line 73 def authentication_challenge services.authz.challenge(:realm => "Roadforest") end |
#authorization(request) ⇒ Object
63 64 65 66 67 68 69 70 71 |
# File 'lib/roadforest/interface/application.rb', line 63 def (request) method = request.method required = required_grants(method) if required.empty? :public else services.authz.(request, required) end end |
#canonical_host ⇒ Object
79 80 81 |
# File 'lib/roadforest/interface/application.rb', line 79 def canonical_host services.canonical_host end |
#canonical_uri ⇒ Object
41 42 43 |
# File 'lib/roadforest/interface/application.rb', line 41 def canonical_uri url_for(route_name, params) end |
#create_payload ⇒ Object
140 141 142 |
# File 'lib/roadforest/interface/application.rb', line 140 def create_payload nil end |
#delete ⇒ Object
157 158 159 |
# File 'lib/roadforest/interface/application.rb', line 157 def delete false end |
#error_data(status) ⇒ Object
group Resource interface
88 89 90 |
# File 'lib/roadforest/interface/application.rb', line 88 def error_data(status) nil end |
#etag ⇒ Object
96 97 98 |
# File 'lib/roadforest/interface/application.rb', line 96 def etag nil end |
#exists? ⇒ Boolean
92 93 94 |
# File 'lib/roadforest/interface/application.rb', line 92 def exists? !data.nil? end |
#expires ⇒ Object
132 133 134 |
# File 'lib/roadforest/interface/application.rb', line 132 def expires nil end |
#interface_for(route_name = nil, params = nil) ⇒ Object
37 38 39 |
# File 'lib/roadforest/interface/application.rb', line 37 def interface_for(route_name = nil, params = nil) path_provider.interface_for(route_name, params || self.params) end |
#last_modified ⇒ Object
100 101 102 |
# File 'lib/roadforest/interface/application.rb', line 100 def last_modified nil end |
#my_path ⇒ Object
45 46 47 |
# File 'lib/roadforest/interface/application.rb', line 45 def my_path path_for(route_name, params) end |
#my_url ⇒ Object
49 50 51 |
# File 'lib/roadforest/interface/application.rb', line 49 def my_url canonical_uri.to_s end |
#path_for(route_name = nil, params = nil) ⇒ Object
25 26 27 |
# File 'lib/roadforest/interface/application.rb', line 25 def path_for(route_name = nil, params = nil) path_provider.path_for(route_name, params || self.params) end |
#pattern_for(route_name, vals = nil, extra = nil) ⇒ Object
33 34 35 |
# File 'lib/roadforest/interface/application.rb', line 33 def pattern_for(route_name, vals = nil, extra = nil) path_provider.pattern_for(route_name, vals, extra) end |
#processed ⇒ Object
124 125 126 127 128 129 130 |
# File 'lib/roadforest/interface/application.rb', line 124 def processed [:location, :data].each do |key| unless @response_values.has_key?(key) @response_values[key] = nil end end end |
#required_grants(method) ⇒ Object
57 58 59 60 61 |
# File 'lib/roadforest/interface/application.rb', line 57 def required_grants(method) services.authz.build_grants do |grants| grants.add(:admin) end end |
#reset ⇒ Object
XXX remove?
83 84 |
# File 'lib/roadforest/interface/application.rb', line 83 def reset #XXX remove? end |
#response_data ⇒ Object
114 115 116 117 118 |
# File 'lib/roadforest/interface/application.rb', line 114 def response_data @response_values.fetch(:data) do raise ProcessingSequenceError, "Location not available until request processed" end end |
#response_data=(data) ⇒ Object
120 121 122 |
# File 'lib/roadforest/interface/application.rb', line 120 def response_data=(data) @response_values[:data] = data end |
#response_location ⇒ Object
104 105 106 107 108 |
# File 'lib/roadforest/interface/application.rb', line 104 def response_location @response_values.fetch(:location) do raise ProcessingSequenceError, "Location not available until request processed" end end |
#response_location=(location) ⇒ Object
110 111 112 |
# File 'lib/roadforest/interface/application.rb', line 110 def response_location=(location) @response_values[:location] = location end |
#retrieve ⇒ Object Also known as: retreive
152 153 154 |
# File 'lib/roadforest/interface/application.rb', line 152 def retrieve raise NotImplementedError end |
#update(data) ⇒ Object
144 145 146 |
# File 'lib/roadforest/interface/application.rb', line 144 def update(data) raise NotImplementedError end |
#update_payload ⇒ Object
136 137 138 |
# File 'lib/roadforest/interface/application.rb', line 136 def update_payload nil end |
#url_for(route_name, params = nil) ⇒ Object
29 30 31 |
# File 'lib/roadforest/interface/application.rb', line 29 def url_for(route_name, params = nil) ::RDF::URI.new(Addressable::URI.parse(canonical_host.to_s).join(path_for(route_name, params))) end |