module DogBiscuits::Actors::ApplyAuthorities

Private Instance Methods

add_new(authority_name, label) click to toggle source

Add new term to the authority; it will be rejected if already present

@param auth [String] the authority to add to @param label [String] the label to add

# File lib/dog_biscuits/actors/apply_authorities.rb, line 25
def add_new(authority_name, label)
  DogBiscuits::Importers::Authority.new(authority_name).create_record(label) if Qa::Authorities::Local.subauthority_for(authority_name).search(label).empty?
rescue Qa::InvalidSubAuthority
  Rails.logger.error("Invalid sub-authority: #{auth}")
end
apply_authorities(env) click to toggle source

Add new terms to table-based authorities

@param env [Hyrax::Actors::Environment] the env

# File lib/dog_biscuits/actors/apply_authorities.rb, line 11
def apply_authorities(env)
  DogBiscuits.config.authorities_add_new.each do |authority_name|
    term = authority_name.to_s.singularize.to_sym
    next unless env.attributes.key? term
    env.attributes[term].each do |attr|
      add_new(authority_name.to_s, attr)
    end
  end
end