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.0.8 spec/support/factory_bot.rb
inferno_core-0.0.8.pre2 spec/support/factory_bot.rb
inferno_core-0.0.8.pre spec/support/factory_bot.rb
inferno_core-0.0.7 spec/support/factory_bot.rb
inferno_core-0.0.6 spec/support/factory_bot.rb
inferno_core-0.0.5 spec/support/factory_bot.rb
inferno_core-0.0.4 spec/support/factory_bot.rb
inferno_core-0.0.3 spec/support/factory_bot.rb
inferno_core-0.0.2 spec/support/factory_bot.rb
inferno_core-0.0.1 spec/support/factory_bot.rb