Class: DescribedRoutes::RailsController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- DescribedRoutes::RailsController
show all
- Includes:
- DescribedRoutesHelper
- Defined in:
- lib/described_routes/rails_controller.rb
Constant Summary
DescribedRoutesHelper::LINK_ELEMENT_OPTIONS, DescribedRoutesHelper::LINK_HEADER_OPTIONS, DescribedRoutesHelper::REGISTERED_RELS
Instance Method Summary
collapse
#link_elements, #make_link_header, #resource_parameters, #resource_template, #resource_templates
Instance Method Details
#index ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/described_routes/rails_controller.rb', line 11
def index
expanded_templates = resource_templates.partial_expand(request.query_parameters)
respond_to do |format|
format.html { render rescue redirect_to :format => :text } format.json { render :json => expanded_templates.to_json }
format.text { render :text => expanded_templates.to_text }
format.yaml { render :text => expanded_templates.to_yaml }
format.xml { render :xml => expanded_templates.to_xml(Builder::XmlMarkup.new(:indent => 2)).target! }
end
end
|
38
39
40
41
|
# File 'lib/described_routes/rails_controller.rb', line 38
def
rel = request.path == described_routes_path ? "self" : "index"
response.["Link"] = %Q(<#{described_routes_url}>; rel="#{rel}"; meta="ResourceTemplates")
end
|
#show ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/described_routes/rails_controller.rb', line 23
def show
expanded_templates = resource_templates.partial_expand(request.query_parameters)
resource_template = resource_templates.all_by_name[params[:id]]
resource_template = resource_template.partial_expand(request.query_parameters)
respond_to do |format|
format.html { render rescue redirect_to :format => :text } format.json { render :json => resource_template.to_json }
format.text { render :text => resource_template.to_text }
format.yaml { render :text => resource_template.to_yaml }
format.xml { render :xml => resource_template.to_xml(Builder::XmlMarkup.new(:indent => 2)).target! }
end
end
|