Class: Qa::Authorities::Local
Instance Attribute Summary
#sub_authority
Instance Method Summary
collapse
#names, #sub_authorities_path
#initialize
Methods inherited from Base
#full_record
Instance Method Details
#all ⇒ Object
17
18
19
20
21
|
# File 'lib/qa/authorities/local.rb', line 17
def all
terms.map do |res|
{ :id => res[:id], :label => res[:term] }.with_indifferent_access
end
end
|
#find(id) ⇒ Object
23
24
25
|
# File 'lib/qa/authorities/local.rb', line 23
def find(id)
terms.find { |term| term[:id] == id } || {}
end
|
#search(q) ⇒ Object
10
11
12
13
14
15
|
# File 'lib/qa/authorities/local.rb', line 10
def search(q)
r = q.blank? ? [] : terms.select { |term| /\b#{q.downcase}/.match(term[:term].downcase) }
r.map do |res|
{ :id => res[:id], :label => res[:term] }.with_indifferent_access
end
end
|
#sub_authorities ⇒ Object
6
7
8
|
# File 'lib/qa/authorities/local.rb', line 6
def sub_authorities
names
end
|