Sha256: bdaf20a919e87d49e25933f3cc333de309d9bedb720264234f8d9d3c6f9c6688

Contents?: true

Size: 463 Bytes

Versions: 11

Compression:

Stored size: 463 Bytes

Contents

module FactoryBot
  # @api private
  class StrategyCalculator
    def initialize(name_or_object)
      @name_or_object = name_or_object
    end

    def strategy
      if strategy_is_object?
        @name_or_object
      else
        strategy_name_to_object
      end
    end

    private

    def strategy_is_object?
      @name_or_object.is_a?(Class)
    end

    def strategy_name_to_object
      FactoryBot.strategy_by_name(@name_or_object)
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
factory_bot-5.0.2 lib/factory_bot/strategy_calculator.rb
factory_bot-5.0.1 lib/factory_bot/strategy_calculator.rb
factory_bot-5.0.0 lib/factory_bot/strategy_calculator.rb
factory_bot-5.0.0.rc2 lib/factory_bot/strategy_calculator.rb
factory_bot-5.0.0.rc1 lib/factory_bot/strategy_calculator.rb
factory_bot-4.11.1 lib/factory_bot/strategy_calculator.rb
factory_bot-4.11.0 lib/factory_bot/strategy_calculator.rb
factory_bot-4.10.0 lib/factory_bot/strategy_calculator.rb
factory_bot-4.8.2 lib/factory_bot/strategy_calculator.rb
factory_bot-1.0.1.alpha lib/factory_bot/strategy_calculator.rb
factory_bot-1.0.0.alpha lib/factory_bot/strategy_calculator.rb