Class: Qa::TermsController

Inherits:
ApplicationController show all
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

Instance Method Details

#check_query_paramObject



37
38
39
# File 'app/controllers/qa/terms_controller.rb', line 37

def check_query_param
  head :not_found unless params[:q].present?
end

#check_vocab_paramObject



27
28
29
# File 'app/controllers/qa/terms_controller.rb', line 27

def check_vocab_param
  head :not_found unless params[:vocab].present?
end

#indexObject

If the subauthority supports it, return a list of all terms in the authority



11
12
13
# File 'app/controllers/qa/terms_controller.rb', line 11

def index
  render json: @authority.all
end

#init_authorityObject



31
32
33
34
35
# File 'app/controllers/qa/terms_controller.rb', line 31

def init_authority
  @authority = authority_class.constantize.new(params[:sub_authority])
rescue
  head :not_found
end

#searchObject

Return a list of terms based on a query



16
17
18
19
# File 'app/controllers/qa/terms_controller.rb', line 16

def search
  terms = @authority.search(url_search)
  render json: terms
end

#showObject

If the subauthority supports it, return all the information for a given term



22
23
24
25
# File 'app/controllers/qa/terms_controller.rb', line 22

def show
  term = @authority.find(params[:id])
  render json: term
end