Class: FactoryBot::Trait Private
- Inherits:
-
Object
- Object
- FactoryBot::Trait
- Defined in:
- lib/factory_bot/trait.rb
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.
Instance Attribute Summary collapse
- #definition ⇒ Object readonly private
- #name ⇒ Object readonly private
- #uid ⇒ Object readonly private
Instance Method Summary collapse
- #==(other) ⇒ Object private
- #clone ⇒ Object private
-
#initialize(name, **options, &block) ⇒ Trait
constructor
private
A new instance of Trait.
- #names ⇒ Object private
Constructor Details
#initialize(name, **options, &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.
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/factory_bot/trait.rb', line 9 def initialize(name, **, &block) @name = name.to_s @block = block @uri_manager = FactoryBot::UriManager.new(names, paths: [:uri_paths]) @definition = Definition.new(@name, uri_manager: @uri_manager) proxy = FactoryBot::DefinitionProxy.new(@definition) if block proxy.instance_eval(&@block) end end |
Instance Attribute Details
#definition ⇒ Object (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.
4 5 6 |
# File 'lib/factory_bot/trait.rb', line 4 def definition @definition end |
#name ⇒ Object (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.
4 5 6 |
# File 'lib/factory_bot/trait.rb', line 4 def name @name end |
#uid ⇒ Object (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.
4 5 6 |
# File 'lib/factory_bot/trait.rb', line 4 def uid @uid 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.
30 31 32 33 |
# File 'lib/factory_bot/trait.rb', line 30 def ==(other) name == other.name && block == other.block end |
#clone ⇒ 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.
22 23 24 |
# File 'lib/factory_bot/trait.rb', line 22 def clone Trait.new(name, uri_paths: definition.uri_manager.paths, &block) end |
#names ⇒ 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.
26 27 28 |
# File 'lib/factory_bot/trait.rb', line 26 def names [@name] end |