Sha256: 202ecaf2de8ce88b16e967347904e2b1b24766ad9a7b22e37396e1185ca19179

Contents?: true

Size: 775 Bytes

Versions: 1

Compression:

Stored size: 775 Bytes

Contents

module Qa::Authorities

  class Local < Qa::Authorities::Base

    class << self
      def sub_authority(name)
        @sub_authorities ||= {}
        raise ArgumentError, "Invalid sub-authority '#{name}'" unless Subauthority.names.include?(name)
        @sub_authorities[name] ||= Subauthority.new(name)
      end

      def sub_authorities
        Subauthority.names
      end

      def terms(sub_authority)
        sub_authority(sub_authority).terms
      end
    end

    def search(q, sub_authority)
      Local.sub_authority(sub_authority).search(q)
    end

    def get_full_record(id, sub_authority)
      terms = Local.sub_authority(sub_authority).terms
      terms.each do |term|
        return term if term[:id] == id
      end
      return {}
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
qa-0.0.2 lib/qa/authorities/local.rb