Sha256: 14051e4c837e99c7eb723f81a2aa6c8595a6a3f9011c39b20125ee8ae07530fc

Contents?: true

Size: 789 Bytes

Versions: 5

Compression:

Stored size: 789 Bytes

Contents

module FactoryBot
  class Declaration
    # @api private
    class Implicit < Declaration
      def initialize(name, factory = nil, ignored = false)
        super(name, ignored)
        @factory = factory
      end

      def ==(other)
        self.class == other.class &&
          name == other.name &&
          factory == other.factory &&
          ignored == other.ignored
      end

      protected

      attr_reader :factory

      private

      def build
        if FactoryBot.factories.registered?(name)
          [Attribute::Association.new(name, name, {})]
        elsif FactoryBot.sequences.registered?(name)
          [Attribute::Sequence.new(name, name, @ignored)]
        else
          @factory.inherit_traits([name])
          []
        end
      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/implicit.rb
factory_bot-5.0.1 lib/factory_bot/declaration/implicit.rb
factory_bot-5.0.0 lib/factory_bot/declaration/implicit.rb
factory_bot-5.0.0.rc2 lib/factory_bot/declaration/implicit.rb
factory_bot-5.0.0.rc1 lib/factory_bot/declaration/implicit.rb