Sha256: 47cd742ecca418afbe2a0ed1223d7ca3e4e5869cd01a9ed2f3c541a0f9aa7462

Contents?: true

Size: 660 Bytes

Versions: 10

Compression:

Stored size: 660 Bytes

Contents

module FactoryBot
  # @api private
  class Trait
    attr_reader :name, :definition

    def initialize(name, &block)
      @name = name.to_s
      @block = block
      @definition = Definition.new(@name)
      proxy = FactoryBot::DefinitionProxy.new(@definition)

      if block
        proxy.instance_eval(&@block)
      end
    end

    delegate :add_callback, :declare_attribute, :to_create, :define_trait, :constructor,
      :callbacks, :attributes, :klass, :klass=, to: :@definition

    def names
      [@name]
    end

    def ==(other)
      name == other.name &&
        block == other.block
    end

    protected

    attr_reader :block
  end
end

Version data entries

10 entries across 9 versions & 3 rubygems

Version Path
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.1.0/gems/factory_bot-6.5.0/lib/factory_bot/trait.rb
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.3.0/gems/factory_bot-6.5.0/lib/factory_bot/trait.rb
factory_bot-6.5.0 lib/factory_bot/trait.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/factory_bot-6.4.6/lib/factory_bot/trait.rb
factory_bot-6.4.6 lib/factory_bot/trait.rb
factory_bot-6.4.5 lib/factory_bot/trait.rb
factory_bot-6.4.4 lib/factory_bot/trait.rb
factory_bot-6.4.3 lib/factory_bot/trait.rb
factory_bot-6.4.2 lib/factory_bot/trait.rb
factory_bot-6.4.1 lib/factory_bot/trait.rb