Sha256: a96aa1791050307b717da81381d286c99dac2f9252e6cc1c93047faa462e7f62

Contents?: true

Size: 1.14 KB

Versions: 23

Compression:

Stored size: 1.14 KB

Contents

module Hyrax
  # A work should be able to be filtered out of search results if it's inactive
  module Suppressible
    extend ActiveSupport::Concern

    included do
      # This holds the workflow state
      property :state, predicate: Vocab::FedoraResourceStatus.objState, multiple: false
    end

    ##
    # Used to restrict visibility on search results for a work that is inactive. If the state is not set, the
    # default behavior is to consider the work not to be suppressed.
    #
    # Override this method if you have some criteria by which records should not display in the search results.
    def suppressed?
      return false if state.nil?
      # This is a clumsy check only needed under RDF < 2.0 where there
      # is a bug with `AT::Resource#==`
      if RDF::VERSION.to_s < '2.0'
        return state.rdf_subject == Vocab::FedoraResourceStatus.inactive
      end
      state == Vocab::FedoraResourceStatus.inactive
    end

    def to_sipity_entity
      raise "Can't create an entity until the model has been persisted" unless persisted?
      @sipity_entity ||= Sipity::Entity.find_by(proxy_for_global_id: to_global_id.to_s)
    end
  end
end

Version data entries

23 entries across 23 versions & 2 rubygems

Version Path
hyrax-1.1.1 app/models/concerns/hyrax/suppressible.rb
hyrax-2.0.3 app/models/concerns/hyrax/suppressible.rb
hyrax-1.1.0 app/models/concerns/hyrax/suppressible.rb
hyrax-2.0.2 app/models/concerns/hyrax/suppressible.rb
hyrax-2.1.0.beta1 app/models/concerns/hyrax/suppressible.rb
hyrax-2.0.1 app/models/concerns/hyrax/suppressible.rb
hyrax-2.0.0 app/models/concerns/hyrax/suppressible.rb
hyrax-2.0.0.rc3 app/models/concerns/hyrax/suppressible.rb
hyrax-2.0.0.rc2 app/models/concerns/hyrax/suppressible.rb
hyrax-2.0.0.rc1 app/models/concerns/hyrax/suppressible.rb
hyrax-1.0.5 app/models/concerns/hyrax/suppressible.rb
hyrax-2.0.0.beta5 app/models/concerns/hyrax/suppressible.rb
hyrax-2.0.0.beta4 app/models/concerns/hyrax/suppressible.rb
hyrax-2.0.0.beta3 app/models/concerns/hyrax/suppressible.rb
hyrax-2.0.0.beta2 app/models/concerns/hyrax/suppressible.rb
hyrax-2.0.0.beta1 app/models/concerns/hyrax/suppressible.rb
hyrax-1.0.4 app/models/concerns/hyrax/suppressible.rb
hyrax-1.0.3 app/models/concerns/hyrax/suppressible.rb
hyrax-1.0.2 app/models/concerns/hyrax/suppressible.rb
hyrax-1.0.1 app/models/concerns/hyrax/suppressible.rb