Sha256: f205facd8d65268b78227e90cabae18cf47f7fd074bfc5c70389f4ebbd1bfef8

Contents?: true

Size: 503 Bytes

Versions: 30

Compression:

Stored size: 503 Bytes

Contents

class CreateStrategy
  def initialize
    @strategy = FactoryBot.strategy_by_name(:create).new
  end

  delegate :association, to: :@strategy

  def result(evaluation)
    result = nil
    evaluation.object.tap do |instance|
      evaluation.notify(:after_build, instance)
      evaluation.notify(:before_create, instance)
      result = evaluation.create(instance)
      evaluation.notify(:after_create, result)
    end

    result
  end
end

FactoryBot.register_strategy(:repo_create, CreateStrategy)

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
inferno_core-0.3.3 spec/support/factory_bot.rb
inferno_core-0.3.2 spec/support/factory_bot.rb
inferno_core-0.3.1 spec/support/factory_bot.rb
inferno_core-0.3.0 spec/support/factory_bot.rb
inferno_core-0.3.0.rc1 spec/support/factory_bot.rb
inferno_core-0.2.0 spec/support/factory_bot.rb
inferno_core-0.2.0.rc4 spec/support/factory_bot.rb
inferno_core-0.2.0.rc3 spec/support/factory_bot.rb
inferno_core-0.2.0.rc2 spec/support/factory_bot.rb
inferno_core-0.2.0.rc1 spec/support/factory_bot.rb
inferno_core-0.1.4.pre spec/support/factory_bot.rb
inferno_core-0.1.3 spec/support/factory_bot.rb
inferno_core-0.1.3.pre2 spec/support/factory_bot.rb
inferno_core-0.1.3.pre spec/support/factory_bot.rb
inferno_core-0.1.2 spec/support/factory_bot.rb
inferno_core-0.1.2.pre spec/support/factory_bot.rb
inferno_core-0.1.1 spec/support/factory_bot.rb
inferno_core-0.1.1.pre spec/support/factory_bot.rb
inferno_core-0.1.0 spec/support/factory_bot.rb
inferno_core-0.1.0.pre spec/support/factory_bot.rb