Sha256: 8028852f59348eeb2221162409246c09c2e455fe88531adf78e2bde72fde1ca1

Contents?: true

Size: 710 Bytes

Versions: 14

Compression:

Stored size: 710 Bytes

Contents

# frozen_string_literal: true
# @see https://github.com/thoughtbot/factory_bot/blob/master/GETTING_STARTED.md#custom-strategies
# @example
#   let(:resource) { FactoryBot.valkyrie_create(:hyrax_work) }
class ValkyrieCreateStrategy
  def initialize
    @strategy = FactoryBot.strategy_by_name(:create).new
  end

  delegate :association, to: :@strategy

  def result(evaluation)
    evaluation.notify(:after_build, evaluation.object)
    evaluation.notify(:before_create, evaluation.object)

    result = persister.save(resource: evaluation.object)

    evaluation.notify(:after_create, result)
    result
  end

  def to_sym
    :valkyrie_create
  end

  private

  def persister
    Hyrax.persister
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
hyrax-5.1.0.pre.beta1 lib/hyrax/specs/shared_specs/factories/strategies/valkyrie_resource.rb
hyrax-5.0.4 lib/hyrax/specs/shared_specs/factories/strategies/valkyrie_resource.rb
hyrax-5.0.3 lib/hyrax/specs/shared_specs/factories/strategies/valkyrie_resource.rb
hyrax-5.0.2 lib/hyrax/specs/shared_specs/factories/strategies/valkyrie_resource.rb
hyrax-5.0.1 lib/hyrax/specs/shared_specs/factories/strategies/valkyrie_resource.rb
hyrax-5.0.0 lib/hyrax/specs/shared_specs/factories/strategies/valkyrie_resource.rb
hyrax-5.0.0.rc3 lib/hyrax/specs/shared_specs/factories/strategies/valkyrie_resource.rb
hyrax-5.0.0.rc2 lib/hyrax/specs/shared_specs/factories/strategies/valkyrie_resource.rb
hyrax-5.0.0.rc1 lib/hyrax/specs/shared_specs/factories/strategies/valkyrie_resource.rb
hyrax-4.0.0 lib/hyrax/specs/shared_specs/factories/strategies/valkyrie_resource.rb
hyrax-4.0.0.rc3 lib/hyrax/specs/shared_specs/factories/strategies/valkyrie_resource.rb
hyrax-4.0.0.rc2 lib/hyrax/specs/shared_specs/factories/strategies/valkyrie_resource.rb
hyrax-4.0.0.rc1 lib/hyrax/specs/shared_specs/factories/strategies/valkyrie_resource.rb
hyrax-4.0.0.beta2 lib/hyrax/specs/shared_specs/factories/strategies/valkyrie_resource.rb