Sha256: ec51f100d721f759a3a55a7fe499a1f744cae21f49943c0a165c0b80b7b9c793

Contents?: true

Size: 710 Bytes

Versions: 54

Compression:

Stored size: 710 Bytes

Contents

# frozen_string_literal: true
module Hyrax
  ##
  # A more tolerant `QaSelectService`. This service treats terms with no
  # `active:` property as active terms, instead of erroring with `eKeyError`.
  class TolerantSelectService < QaSelectService
    ##
    # @return [Boolean] indicates whether the term is active;
    #   false if the term is inactive or does not exist; defaults to true when
    #   no key is given
    def active?(id)
      authority.find(id)&.fetch('active', true)
    end

    ##
    # @return [Enumerable<Hash>]
    #
    # @raise [KeyError] when no 'term' value is present for the id
    def active_elements
      authority.all.select { |e| e.fetch('active', true) }
    end
  end
end

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
hyrax-5.0.1 app/services/hyrax/tolerant_select_service.rb
hyrax-5.0.0 app/services/hyrax/tolerant_select_service.rb
hyrax-5.0.0.rc3 app/services/hyrax/tolerant_select_service.rb
hyrax-5.0.0.rc2 app/services/hyrax/tolerant_select_service.rb
hyrax-5.0.0.rc1 app/services/hyrax/tolerant_select_service.rb
hyrax-3.6.0 app/services/hyrax/tolerant_select_service.rb
hyrax-4.0.0 app/services/hyrax/tolerant_select_service.rb
hyrax-4.0.0.rc3 app/services/hyrax/tolerant_select_service.rb
hyrax-4.0.0.rc2 app/services/hyrax/tolerant_select_service.rb
hyrax-4.0.0.rc1 app/services/hyrax/tolerant_select_service.rb
hyrax-3.5.0 app/services/hyrax/tolerant_select_service.rb
hyrax-4.0.0.beta2 app/services/hyrax/tolerant_select_service.rb
hyrax-3.4.2 app/services/hyrax/tolerant_select_service.rb
hyrax-4.0.0.beta1 app/services/hyrax/tolerant_select_service.rb
hyrax-3.4.1 app/services/hyrax/tolerant_select_service.rb
hyrax-3.4.0 app/services/hyrax/tolerant_select_service.rb
hyrax-3.3.0 app/services/hyrax/tolerant_select_service.rb
hyrax-3.2.0 app/services/hyrax/tolerant_select_service.rb
hyrax-2.9.6 app/services/hyrax/tolerant_select_service.rb
hyrax-3.1.0 app/services/hyrax/tolerant_select_service.rb