Sha256: edd6303b373c36057ae1f67dafc95ec8cd06e27c2308e3337ae32f5f88da963f

Contents?: true

Size: 770 Bytes

Versions: 6

Compression:

Stored size: 770 Bytes

Contents

module Hyrax
  module Actors
    class AssignRepresentativeActor < AbstractActor
      # @param [Hyrax::Actors::Environment] env
      # @return [Boolean] true if create was successful
      def create(env)
        next_actor.create(env) && assign_representative(env)
      end

      private

        def assign_representative(env)
          unless env.curation_concern.representative_id
            # TODO: Possible optimization here. Does this cause a fetch of ordered_members if they're already loaded?
            representative = nil # curation_concern.ordered_members.association.reader.first.target
            env.curation_concern.representative = representative if representative
          end
          env.curation_concern.save
        end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
hyrax-2.0.0.rc1 app/actors/hyrax/actors/assign_representative_actor.rb
hyrax-2.0.0.beta5 app/actors/hyrax/actors/assign_representative_actor.rb
hyrax-2.0.0.beta4 app/actors/hyrax/actors/assign_representative_actor.rb
hyrax-2.0.0.beta3 app/actors/hyrax/actors/assign_representative_actor.rb
hyrax-2.0.0.beta2 app/actors/hyrax/actors/assign_representative_actor.rb
hyrax-2.0.0.beta1 app/actors/hyrax/actors/assign_representative_actor.rb