Module: Hyrax::ContainedInWorksBehavior

Included in:
Forms::FileSetForm, Forms::PcdmObjectForm, Forms::ResourceBatchEditForm
Defined in:
app/forms/concerns/hyrax/contained_in_works_behavior.rb

Overview

A module of form behaviours for resources which can be contained in works.

Constant Summary collapse

InWorksPrepopulator =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

proc do |_options|
  self.in_works_ids =
    if persisted?
      Hyrax.query_service
           .find_inverse_references_by(resource: model, property: :member_ids)
           .select(&:work?)
           .map(&:id)
    else
      []
    end
end

Class Method Summary collapse

Class Method Details

.included(descendant) ⇒ Object



20
21
22
# File 'app/forms/concerns/hyrax/contained_in_works_behavior.rb', line 20

def self.included(descendant)
  descendant.property :in_works_ids, virtual: true, prepopulator: InWorksPrepopulator
end