Sha256: 4870d0c20a41d9de5d1f68ba4f6907bd32bbad501c5062adb2682439878580d5

Contents?: true

Size: 1 KB

Versions: 5

Compression:

Stored size: 1 KB

Contents

module RightsService
  extend Deprecation
  mattr_accessor :authority
  begin
    self.authority = Qa::Authorities::Local.subauthority_for('rights')
  rescue Qa::InvalidSubAuthority
    Deprecation.warn(RightsService, "You are using the deprecated RightsService module, but you do not have 'rights.yml'. Switch to CurationConcerns::LicenseService instead")
    self.authority = Qa::Authorities::Local.subauthority_for('licenses')
  end

  def self.select_all_options
    Deprecation.warn(RightsService, "RightsService is deprecated. Use CurationConcerns::LicenseService instead. This will be removed in curation_concerns 2.0")
    authority.all.map do |element|
      [element[:label], element[:id]]
    end
  end

  def self.select_active_options
    active_elements.map { |e| [e[:label], e[:id]] }
  end

  def self.active?(id)
    authority.find(id).fetch('active')
  end

  def self.label(id)
    authority.find(id).fetch('term')
  end

  def self.active_elements
    authority.all.select { |e| active?(e[:id]) }
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
curation_concerns-1.6.3 app/services/rights_service.rb
curation_concerns-1.6.2 app/services/rights_service.rb
curation_concerns-1.6.1 app/services/rights_service.rb
curation_concerns-1.6.0 app/services/rights_service.rb
curation_concerns-1.5.0 app/services/rights_service.rb