Class: FactoryGirl::Definition Private
- Inherits:
-
Object
- Object
- FactoryGirl::Definition
- Defined in:
- lib/factory_girl/definition.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
- #callbacks ⇒ Object readonly private
- #constructor ⇒ Object readonly private
- #declarations ⇒ Object readonly private
- #defined_traits ⇒ Object readonly private
Instance Method Summary collapse
- #add_callback(callback) ⇒ Object private
- #append_traits(new_traits) ⇒ Object private
- #attributes ⇒ Object private
- #compile ⇒ Object private
- #compiled_constructor ⇒ Object private
- #compiled_to_create ⇒ Object private
- #define_constructor(&block) ⇒ Object private
- #define_trait(trait) ⇒ Object private
- #definition_list ⇒ Object private
- #inherit_traits(new_traits) ⇒ Object private
-
#initialize(name = nil, base_traits = []) ⇒ Definition
constructor
private
A new instance of Definition.
- #overridable ⇒ Object private
- #skip_create ⇒ Object private
- #to_create(&block) ⇒ Object private
Constructor Details
#initialize(name = nil, base_traits = []) ⇒ Definition
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 Definition.
6 7 8 9 10 11 12 13 14 |
# File 'lib/factory_girl/definition.rb', line 6 def initialize(name = nil, base_traits = []) @declarations = DeclarationList.new(name) @callbacks = [] @defined_traits = [] @to_create = nil @base_traits = base_traits @additional_traits = [] @constructor = nil end |
Instance Attribute Details
#callbacks ⇒ 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_girl/definition.rb', line 4 def callbacks @callbacks end |
#constructor ⇒ 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_girl/definition.rb', line 4 def constructor @constructor end |
#declarations ⇒ 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_girl/definition.rb', line 4 def declarations @declarations end |
#defined_traits ⇒ 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_girl/definition.rb', line 4 def defined_traits @defined_traits end |
Instance Method Details
#add_callback(callback) ⇒ 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.
45 46 47 |
# File 'lib/factory_girl/definition.rb', line 45 def add_callback(callback) @callbacks << callback end |
#append_traits(new_traits) ⇒ 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.
41 42 43 |
# File 'lib/factory_girl/definition.rb', line 41 def append_traits(new_traits) @additional_traits += new_traits end |
#attributes ⇒ 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.
18 19 20 |
# File 'lib/factory_girl/definition.rb', line 18 def attributes @attributes ||= declarations.attribute_list end |
#compile ⇒ 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_girl/definition.rb', line 22 def compile attributes end |
#compiled_constructor ⇒ 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.
53 54 55 |
# File 'lib/factory_girl/definition.rb', line 53 def compiled_constructor definition_list.constructor end |
#compiled_to_create ⇒ 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.
49 50 51 |
# File 'lib/factory_girl/definition.rb', line 49 def compiled_to_create definition_list.to_create end |
#define_constructor(&block) ⇒ 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.
73 74 75 |
# File 'lib/factory_girl/definition.rb', line 73 def define_constructor(&block) @constructor = block end |
#define_trait(trait) ⇒ 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.
69 70 71 |
# File 'lib/factory_girl/definition.rb', line 69 def define_trait(trait) @defined_traits << trait end |
#definition_list ⇒ 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 29 30 |
# File 'lib/factory_girl/definition.rb', line 26 def definition_list DefinitionList.new( base_traits.map(&:definition) + [self] + additional_traits.map(&:definition) ) end |
#inherit_traits(new_traits) ⇒ 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.
37 38 39 |
# File 'lib/factory_girl/definition.rb', line 37 def inherit_traits(new_traits) @base_traits += new_traits end |
#overridable ⇒ 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.
32 33 34 35 |
# File 'lib/factory_girl/definition.rb', line 32 def overridable declarations.overridable self end |
#skip_create ⇒ 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.
65 66 67 |
# File 'lib/factory_girl/definition.rb', line 65 def skip_create @to_create = ->(instance) { } end |
#to_create(&block) ⇒ 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.
57 58 59 60 61 62 63 |
# File 'lib/factory_girl/definition.rb', line 57 def to_create(&block) if block_given? @to_create = block else @to_create end end |