Sha256: e3ff2417d456a40c6f435a119733c83218038178f4942824d9ae6ac446e142a2

Contents?: true

Size: 667 Bytes

Versions: 5

Compression:

Stored size: 667 Bytes

Contents

module FactoryBot
  class Declaration
    # @api private
    class Association < Declaration
      def initialize(name, *options)
        super(name, false)
        @options = options.dup
        @overrides = options.extract_options!
        @traits = options
      end

      def ==(other)
        self.class == other.class &&
          name == other.name &&
          options == other.options
      end

      protected

      attr_reader :options

      private

      def build
        factory_name = @overrides[:factory] || name
        [Attribute::Association.new(name, factory_name, [@traits, @overrides.except(:factory)].flatten)]
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
factory_bot-5.0.2 lib/factory_bot/declaration/association.rb
factory_bot-5.0.1 lib/factory_bot/declaration/association.rb
factory_bot-5.0.0 lib/factory_bot/declaration/association.rb
factory_bot-5.0.0.rc2 lib/factory_bot/declaration/association.rb
factory_bot-5.0.0.rc1 lib/factory_bot/declaration/association.rb