Sha256: 33085e98d452e749ddcfcc13fa99b8fadbac9146f79c10948996597863f21d3a

Contents?: true

Size: 806 Bytes

Versions: 1

Compression:

Stored size: 806 Bytes

Contents

# frozen_string_literal: true

module RDF
  class CustomIsChildTerm < Vocabulary('http://id.loc.gov/vocabulary/identifiers/')
    property 'is_child'
  end
end

module IiifPrint
  module SetChildFlag
    extend ActiveSupport::Concern
    included do
      # Why the try? A work type's GeneratedResourceSchema goes through this path as well
      # and does not have an #after_save resulting in a NoMethodError.
      try(:after_save, :set_children)
      property :is_child,
              predicate: ::RDF::CustomIsChildTerm.is_child,
              multiple: false do |index|
                index.as :stored_searchable
              end
    end

    def set_children
      ordered_works.each do |child_work|
        child_work.update(is_child: true) unless child_work.is_child
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
iiif_print-1.0.0 app/models/concerns/iiif_print/set_child_flag.rb