Sha256: ecd7ac9adcce9f1636080463869108ee76f1c77a32c2b8106a0cbd0fedfe86b3

Contents?: true

Size: 1.26 KB

Versions: 25

Compression:

Stored size: 1.26 KB

Contents

# frozen_string_literal: true
module Hyrax
  module Actors
    # This is a proxy for the model specific actor
    class ModelActor < AbstractActor
      # See: https://github.com/bbatsov/rubocop/issues/5393
      # rubocop:disable Rails/Delegate

      # @param [Hyrax::Actors::Environment] env
      # @return [Boolean] true if update was successful
      def update(env)
        model_actor(env).update(env)
      end

      # @param [Hyrax::Actors::Environment] env
      # @return [Boolean] true if create was successful
      def create(env)
        model_actor(env).create(env)
      end

      # @param [Hyrax::Actors::Environment] env
      # @return [Boolean] true if destroy was successful
      def destroy(env)
        model_actor(env).destroy(env)
      end
      # rubocop:enable Rails/Delegate

      private

      def model_actor(env)
        actor_identifier = env.curation_concern.class
        klass = "Hyrax::Actors::#{actor_identifier}Actor".constantize
        klass.new(next_actor)
      rescue NameError => error
        Hyrax.logger.info 'No ModelActor provided for ' \
                          "#{env.curation_concern.class}; falling back on " \
                          "NullActor\n\t#{error}"

        NullActor.new(next_actor)
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
hyrax-5.0.1 app/actors/hyrax/actors/model_actor.rb
hyrax-5.0.0 app/actors/hyrax/actors/model_actor.rb
hyrax-5.0.0.rc3 app/actors/hyrax/actors/model_actor.rb
hyrax-5.0.0.rc2 app/actors/hyrax/actors/model_actor.rb
hyrax-5.0.0.rc1 app/actors/hyrax/actors/model_actor.rb
hyrax-3.6.0 app/actors/hyrax/actors/model_actor.rb
hyrax-4.0.0 app/actors/hyrax/actors/model_actor.rb
hyrax-4.0.0.rc3 app/actors/hyrax/actors/model_actor.rb
hyrax-4.0.0.rc2 app/actors/hyrax/actors/model_actor.rb
hyrax-4.0.0.rc1 app/actors/hyrax/actors/model_actor.rb
hyrax-3.5.0 app/actors/hyrax/actors/model_actor.rb
hyrax-4.0.0.beta2 app/actors/hyrax/actors/model_actor.rb
hyrax-3.4.2 app/actors/hyrax/actors/model_actor.rb
hyrax-4.0.0.beta1 app/actors/hyrax/actors/model_actor.rb
hyrax-3.4.1 app/actors/hyrax/actors/model_actor.rb
hyrax-3.4.0 app/actors/hyrax/actors/model_actor.rb
hyrax-3.3.0 app/actors/hyrax/actors/model_actor.rb
hyrax-3.2.0 app/actors/hyrax/actors/model_actor.rb
hyrax-3.1.0 app/actors/hyrax/actors/model_actor.rb
hyrax-3.0.2 app/actors/hyrax/actors/model_actor.rb