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-2.5.0 app/services/hyrax/tolerant_select_service.rb
hyrax-3.0.0.pre.beta2 app/services/hyrax/tolerant_select_service.rb
hyrax-2.4.1 app/services/hyrax/tolerant_select_service.rb
hyrax-3.0.0.pre.beta1 app/services/hyrax/tolerant_select_service.rb
hyrax-2.4.0 app/services/hyrax/tolerant_select_service.rb
hyrax-2.3.3 app/services/hyrax/tolerant_select_service.rb
hyrax-2.3.2 app/services/hyrax/tolerant_select_service.rb
hyrax-2.3.1 app/services/hyrax/tolerant_select_service.rb
hyrax-2.3.0 app/services/hyrax/tolerant_select_service.rb
hyrax-2.2.4 app/services/hyrax/tolerant_select_service.rb
hyrax-2.2.3 app/services/hyrax/tolerant_select_service.rb
hyrax-2.2.2 app/services/hyrax/tolerant_select_service.rb
hyrax-2.2.1 app/services/hyrax/tolerant_select_service.rb
hyrax-2.2.0 app/services/hyrax/tolerant_select_service.rb