Sha256: 9c49885333161769dbaf4a2ea288df30124df6cc04398ad9b6e2ab55d44bef38

Contents?: true

Size: 590 Bytes

Versions: 15

Compression:

Stored size: 590 Bytes

Contents

module FactoryBot
  class Attribute
    # @api private
    class Association < Attribute
      attr_reader :factory

      def initialize(name, factory, overrides)
        super(name, false)
        @factory   = factory
        @overrides = overrides
      end

      def to_proc
        factory   = @factory
        overrides = @overrides
        traits_and_overrides = [factory, overrides].flatten
        factory_name = traits_and_overrides.shift

        -> { association(factory_name, *traits_and_overrides) }
      end

      def association?
        true
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
factory_bot-5.2.0 lib/factory_bot/attribute/association.rb
factory_bot-5.1.2 lib/factory_bot/attribute/association.rb
factory_bot-5.1.1 lib/factory_bot/attribute/association.rb
factory_bot-5.1.0 lib/factory_bot/attribute/association.rb
factory_bot-5.0.2 lib/factory_bot/attribute/association.rb
factory_bot-5.0.1 lib/factory_bot/attribute/association.rb
factory_bot-5.0.0 lib/factory_bot/attribute/association.rb
factory_bot-5.0.0.rc2 lib/factory_bot/attribute/association.rb
factory_bot-5.0.0.rc1 lib/factory_bot/attribute/association.rb
factory_bot-4.11.1 lib/factory_bot/attribute/association.rb
factory_bot-4.11.0 lib/factory_bot/attribute/association.rb
factory_bot-4.10.0 lib/factory_bot/attribute/association.rb
factory_bot-4.8.2 lib/factory_bot/attribute/association.rb
factory_bot-1.0.1.alpha lib/factory_bot/attribute/association.rb
factory_bot-1.0.0.alpha lib/factory_bot/attribute/association.rb