Sha256: 9a34a6429d7f43d077f08bbe49c00e7a4fd608a7571f7be1da2e7e4ed3743637

Contents?: true

Size: 586 Bytes

Versions: 19

Compression:

Stored size: 586 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

19 entries across 18 versions & 3 rubygems

Version Path
factory_bot-6.5.1 lib/factory_bot/attribute/association.rb
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.1.0/gems/factory_bot-6.5.0/lib/factory_bot/attribute/association.rb
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.3.0/gems/factory_bot-6.5.0/lib/factory_bot/attribute/association.rb
factory_bot-6.5.0 lib/factory_bot/attribute/association.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/factory_bot-6.4.6/lib/factory_bot/attribute/association.rb
factory_bot-6.4.6 lib/factory_bot/attribute/association.rb
factory_bot-6.4.5 lib/factory_bot/attribute/association.rb
factory_bot-6.4.4 lib/factory_bot/attribute/association.rb
factory_bot-6.4.3 lib/factory_bot/attribute/association.rb
factory_bot-6.4.2 lib/factory_bot/attribute/association.rb
factory_bot-6.4.1 lib/factory_bot/attribute/association.rb
factory_bot-6.4.0 lib/factory_bot/attribute/association.rb
factory_bot-6.3.0 lib/factory_bot/attribute/association.rb
factory_bot-6.2.1 lib/factory_bot/attribute/association.rb
factory_bot-6.2.0 lib/factory_bot/attribute/association.rb
factory_bot-6.1.0 lib/factory_bot/attribute/association.rb
factory_bot-6.0.2 lib/factory_bot/attribute/association.rb
factory_bot-6.0.1 lib/factory_bot/attribute/association.rb
factory_bot-6.0.0 lib/factory_bot/attribute/association.rb