Module: Hyrax::LeaseabilityBehavior
- Included in:
- Forms::FileSetForm, Forms::PcdmObjectForm, Forms::ResourceBatchEditForm
- Defined in:
- app/forms/concerns/hyrax/leaseability_behavior.rb
Overview
A module of form behaviours for embargoes, leases, and resulting visibilities.
Class Method Summary collapse
-
.included(descendant) ⇒ Object
rubocop:disable Metrics/AbcSize.
Instance Method Summary collapse
- #embargo_populator ⇒ Object
- #lease_populator ⇒ Object
- #visibility_populator(fragment:, doc:) ⇒ Object
Class Method Details
.included(descendant) ⇒ Object
rubocop:disable Metrics/AbcSize
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/forms/concerns/hyrax/leaseability_behavior.rb', line 7 def self.included(descendant) # rubocop:disable Metrics/AbcSize descendant.property :visibility, default: VisibilityIntention::PRIVATE, populator: :visibility_populator descendant.property :embargo, form: Hyrax::Forms::Embargo, populator: :embargo_populator descendant.property :lease, form: Hyrax::Forms::Lease, populator: :lease_populator # virtual properties for embargo/lease; descendant.property :embargo_release_date, virtual: true, prepopulator: proc { |_opts| self. = model.&. } descendant.property :visibility_after_embargo, virtual: true, prepopulator: proc { |_opts| self. = model.&. } descendant.property :visibility_during_embargo, virtual: true, prepopulator: proc { |_opts| self. = model.&. } descendant.property :lease_expiration_date, virtual: true, prepopulator: proc { |_opts| self.lease_expiration_date = model.lease&.lease_expiration_date } descendant.property :visibility_after_lease, virtual: true, prepopulator: proc { |_opts| self.visibility_after_lease = model.lease&.visibility_after_lease } descendant.property :visibility_during_lease, virtual: true, prepopulator: proc { |_opts| self.visibility_during_lease = model.lease&.visibility_during_lease } end |
Instance Method Details
#embargo_populator ⇒ Object
23 24 25 |
# File 'app/forms/concerns/hyrax/leaseability_behavior.rb', line 23 def (**) self. = Hyrax::EmbargoManager.(resource: model) end |
#lease_populator ⇒ Object
27 28 29 |
# File 'app/forms/concerns/hyrax/leaseability_behavior.rb', line 27 def lease_populator(**) self.lease = Hyrax::LeaseManager.lease_for(resource: model) end |
#visibility_populator(fragment:, doc:) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/forms/concerns/hyrax/leaseability_behavior.rb', line 31 def visibility_populator(fragment:, doc:, **) case fragment when "embargo" self.visibility = doc['visibility_during_embargo'] doc['embargo'] = doc.slice('visibility_after_embargo', 'visibility_during_embargo', 'embargo_release_date') when "lease" self.visibility = doc['visibility_during_lease'] doc['lease'] = doc.slice('visibility_after_lease', 'visibility_during_lease', 'lease_expiration_date') else self.visibility = fragment end end |