Sha256: cba72f11a3abf3dbf2855b543ea581d490331e4f668f686cbcddb9141e2662bf

Contents?: true

Size: 514 Bytes

Versions: 10

Compression:

Stored size: 514 Bytes

Contents

module FactoryBot
  class Attribute
    # @api private
    class Dynamic < Attribute
      def initialize(name, ignored, block)
        super(name, ignored)
        @block = block
      end

      def to_proc
        block = @block

        -> {
          value = case block.arity
          when 1, -1, -2 then instance_exec(self, &block)
          else instance_exec(&block)
          end
          raise SequenceAbuseError if FactoryBot::Sequence === value

          value
        }
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
factory_bot-6.5.0 lib/factory_bot/attribute/dynamic.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/factory_bot-6.4.6/lib/factory_bot/attribute/dynamic.rb
factory_bot-6.4.6 lib/factory_bot/attribute/dynamic.rb
factory_bot-6.4.5 lib/factory_bot/attribute/dynamic.rb
factory_bot-6.4.4 lib/factory_bot/attribute/dynamic.rb
factory_bot-6.4.3 lib/factory_bot/attribute/dynamic.rb
factory_bot-6.4.2 lib/factory_bot/attribute/dynamic.rb
factory_bot-6.4.1 lib/factory_bot/attribute/dynamic.rb
factory_bot-6.4.0 lib/factory_bot/attribute/dynamic.rb
factory_bot-6.3.0 lib/factory_bot/attribute/dynamic.rb