Class: Qa::TermsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Qa::TermsController
- Defined in:
- app/controllers/qa/terms_controller.rb
Overview
This controller is used for all requests to all authorities. It will verify params and figure out which class to instantiate based on the “vocab” param. All the authotirty classes inherit from a super class so they implement the same methods.
Instance Method Summary collapse
- #check_authority ⇒ Object
- #check_search_params ⇒ Object
- #check_sub_authority ⇒ Object
- #check_vocab_param ⇒ Object
-
#index ⇒ Object
search that returns all results.
- #search ⇒ Object
Instance Method Details
#check_authority ⇒ Object
56 57 58 59 60 61 62 |
# File 'app/controllers/qa/terms_controller.rb', line 56 def begin .constantize rescue redirect_to :status => 400 end end |
#check_search_params ⇒ Object
50 51 52 53 54 |
# File 'app/controllers/qa/terms_controller.rb', line 50 def check_search_params unless params[:q].present? && params[:vocab].present? redirect_to :status => 400 end end |
#check_sub_authority ⇒ Object
64 65 66 67 68 |
# File 'app/controllers/qa/terms_controller.rb', line 64 def unless params[:sub_authority].nil? redirect_to :status => 400 unless .constantize.(params[:sub_authority]) end end |
#check_vocab_param ⇒ Object
44 45 46 47 48 |
# File 'app/controllers/qa/terms_controller.rb', line 44 def check_vocab_param unless params[:vocab].present? redirect_to :status => 400 end end |
#index ⇒ Object
search that returns all results
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/qa/terms_controller.rb', line 11 def index #initialize the authority and run the search. if there's a sub-authority and it's valid, include that param @authority = .constantize.new(params[:q], params[:sub_authority]) #parse the results @authority. respond_to do |format| format.html { render :layout => false, :text => @authority.results } format.json { render :layout => false, :text => @authority.results } format.js { render :layout => false, :text => @authority.results } end end |
#search ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/controllers/qa/terms_controller.rb', line 25 def search #convert wildcard to be URI encoded params[:q].gsub!("*", "%2A") #initialize the authority and run the search. if there's a sub-authority and it's valid, include that param @authority = .constantize.new(params[:q], params[:sub_authority]) #parse the results @authority. respond_to do |format| format.html { render :layout => false, :text => @authority.results } format.json { render :layout => false, :text => @authority.results } format.js { render :layout => false, :text => @authority.results } end end |