module Qa::Authorities::AuthorityWithSubAuthority

Public Instance Methods

new(subauthority = nil) click to toggle source
# File lib/qa/authorities/authority_with_sub_authority.rb, line 3
def new(subauthority = nil)
  raise "Initializing with as sub authority is removed. use #{self.class}.subauthority_for(#{subauthority.inspect}) instead"
end
subauthorities() click to toggle source

By default, an authority has no subauthorities unless they are defined by the subclassed authority.

# File lib/qa/authorities/authority_with_sub_authority.rb, line 22
def subauthorities
  []
end
subauthority_class(name) click to toggle source
# File lib/qa/authorities/authority_with_sub_authority.rb, line 12
def subauthority_class(name)
  [self, name].join('::').classify.constantize
end
subauthority_for(subauthority) click to toggle source
# File lib/qa/authorities/authority_with_sub_authority.rb, line 7
def subauthority_for(subauthority)
  validate_subauthority!(subauthority)
  subauthority_class(subauthority).new
end
validate_subauthority!(subauthority) click to toggle source
# File lib/qa/authorities/authority_with_sub_authority.rb, line 16
def validate_subauthority!(subauthority)
  raise Qa::InvalidSubAuthority, "Unable to initialize sub-authority #{subauthority} for #{self}. Valid sub-authorities are #{subauthorities.inspect}" unless subauthorities.include?(subauthority)
end