Sha256: 12ba0ee2b141db765aa9c3ab239c06555e0af735a77af8175afb1c01a139d655

Contents?: true

Size: 1.09 KB

Versions: 3

Compression:

Stored size: 1.09 KB

Contents

require 'deprecation'

module Qa::Authorities
  class Base
    extend Deprecation

    attr_accessor :sub_authority

    # Registers the authority and its sub-authority if it has one
    def initialize *args
      if args.first
        raise "Invalid sub-authority" unless sub_authorities.include?(args.first)
      end
    end

    # By default, an authority has no subauthorities unless they
    # are defined by the subclassed authority.
    def sub_authorities
      []
    end

    # By default, #all is not implemented.
    # If the subclassed authority does have this feature
    # then you will overide the #all method in the subclassed authority.
    # TODO: need to set some kind of error here
    def all
    end

    # By default, #find is not implemented.
    # If the subclassed authority does have this feature
    # then you will overide the #find method in the subclassed authority.
    # TODO: need to set some kind of error here
    def find id
    end

    def full_record id, sub_authority=nil
      Deprecation.warn(".full_record is deprecated. Use .find instead")
      find(id)
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
qa-0.4.2 lib/qa/authorities/base.rb
qa-0.4.1 lib/qa/authorities/base.rb
qa-0.4.0 lib/qa/authorities/base.rb