Class: Qa::Authorities::Local::FileBasedAuthority
- Defined in:
- lib/qa/authorities/local/file_based_authority.rb
Instance Attribute Summary collapse
-
#subauthority ⇒ Object
readonly
Returns the value of attribute subauthority.
Instance Method Summary collapse
- #all ⇒ Object
- #find(id) ⇒ Object
-
#initialize(subauthority) ⇒ FileBasedAuthority
constructor
A new instance of FileBasedAuthority.
- #search(q) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(subauthority) ⇒ FileBasedAuthority
Returns a new instance of FileBasedAuthority.
4 5 6 |
# File 'lib/qa/authorities/local/file_based_authority.rb', line 4 def initialize() @subauthority = end |
Instance Attribute Details
#subauthority ⇒ Object (readonly)
Returns the value of attribute subauthority.
3 4 5 |
# File 'lib/qa/authorities/local/file_based_authority.rb', line 3 def @subauthority end |
Instance Method Details
#all ⇒ Object
15 16 17 18 19 |
# File 'lib/qa/authorities/local/file_based_authority.rb', line 15 def all terms.map do |res| { :id => res[:id], :label => res[:term] }.with_indifferent_access end end |
#find(id) ⇒ Object
21 22 23 |
# File 'lib/qa/authorities/local/file_based_authority.rb', line 21 def find(id) terms.find { |term| term[:id] == id } || {} end |
#search(q) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/qa/authorities/local/file_based_authority.rb', line 8 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 |