Class: FactoryBot::Trait Private

Inherits:
Object
  • Object
show all
Defined in:
lib/factory_bot/trait.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

API:

  • private

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, &block) ⇒ Trait

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Trait.

API:

  • private



6
7
8
9
10
11
12
13
# File 'lib/factory_bot/trait.rb', line 6

def initialize(name, &block)
  @name = name.to_sym
  @block = block
  @definition = Definition.new(@name)

  proxy = FactoryBot::DefinitionProxy.new(@definition)
  proxy.instance_eval(&@block) if block_given?
end

Instance Attribute Details

#definitionObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



4
5
6
# File 'lib/factory_bot/trait.rb', line 4

def definition
  @definition
end

#nameObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



4
5
6
# File 'lib/factory_bot/trait.rb', line 4

def name
  @name
end

Instance Method Details

#==(other) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



22
23
24
25
# File 'lib/factory_bot/trait.rb', line 22

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

#namesObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



18
19
20
# File 'lib/factory_bot/trait.rb', line 18

def names
  [@name]
end