Class: RemoteLabelsController

Inherits:
ApplicationController show all
Includes:
DatasetInitialization
Defined in:
app/controllers/remote_labels_controller.rb

Instance Method Summary collapse

Methods included from DatasetInitialization

#datasets_as_json, #init_datasets

Instance Method Details

#showObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/remote_labels_controller.rb', line 6

def show
  @datasets = init_datasets

  concept_url = params[:concept_url]

  # ensure known dataset
  @dataset = @datasets.detect { |d| concept_url.to_s.start_with?(d.url.to_s) }
  unless @dataset
    head 422
    return
  end

  label = @dataset.find_label(concept_url)
  unless label
    head 404
    return
  end

  respond_to do |format|
    format.json do
      render json: { label: label }
    end
  end
end