Sha256: 7f865016223b30643faa40dab16331e0ec652fc02304a18d8f58bbab7495ce17

Contents?: true

Size: 947 Bytes

Versions: 20

Compression:

Stored size: 947 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::Internal.sequences.registered?(name)
          [Attribute::Sequence.new(name, name, @ignored)]
        elsif @factory.name.to_s == name.to_s
          message = "Self-referencing trait '#{@name}'"
          raise TraitDefinitionError, message
        else
          @factory.inherit_traits([name])
          []
        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 2 rubygems

Version Path
factory_bot-6.5.0 lib/factory_bot/declaration/implicit.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/factory_bot-6.4.6/lib/factory_bot/declaration/implicit.rb
factory_bot-6.4.6 lib/factory_bot/declaration/implicit.rb
factory_bot-6.4.5 lib/factory_bot/declaration/implicit.rb
factory_bot-6.4.4 lib/factory_bot/declaration/implicit.rb
factory_bot-6.4.3 lib/factory_bot/declaration/implicit.rb
factory_bot-6.4.2 lib/factory_bot/declaration/implicit.rb
factory_bot-6.4.1 lib/factory_bot/declaration/implicit.rb
factory_bot-6.4.0 lib/factory_bot/declaration/implicit.rb
factory_bot-6.3.0 lib/factory_bot/declaration/implicit.rb
factory_bot-6.2.1 lib/factory_bot/declaration/implicit.rb
factory_bot-6.2.0 lib/factory_bot/declaration/implicit.rb
factory_bot-6.1.0 lib/factory_bot/declaration/implicit.rb
factory_bot-6.0.2 lib/factory_bot/declaration/implicit.rb
factory_bot-6.0.1 lib/factory_bot/declaration/implicit.rb
factory_bot-6.0.0 lib/factory_bot/declaration/implicit.rb
factory_bot-5.2.0 lib/factory_bot/declaration/implicit.rb
factory_bot-5.1.2 lib/factory_bot/declaration/implicit.rb
factory_bot-5.1.1 lib/factory_bot/declaration/implicit.rb
factory_bot-5.1.0 lib/factory_bot/declaration/implicit.rb