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)
- - (Object) callbacks readonly private
- - (Object) constructor readonly private
- - (Object) declarations readonly private
- - (Object) defined_traits readonly private
Instance Method Summary (collapse)
- - (Object) add_callback(callback) private
- - (Object) append_traits(new_traits) private
- - (Object) attributes private
- - (Object) compile private
- - (Object) compiled_constructor private
- - (Object) compiled_to_create private
- - (Object) define_constructor(&block) private
- - (Object) define_trait(trait) private
- - (Object) definition_list private
- - (Object) inherit_traits(new_traits) private
-
- (Definition) initialize(name = nil, base_traits = [])
constructor
private
A new instance of Definition.
- - (Object) overridable private
- - (Object) skip_create private
- - (Object) to_create(&block) private
Constructor Details
- (Definition) initialize(name = nil, base_traits = [])
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.
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
- (Object) callbacks (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 |
- (Object) constructor (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 |
- (Object) declarations (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 |
- (Object) defined_traits (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
- (Object) add_callback(callback)
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 |
- (Object) append_traits(new_traits)
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 |
- (Object) attributes
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 |
- (Object) compile
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 |
- (Object) compiled_constructor
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 |
- (Object) compiled_to_create
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 |
- (Object) define_constructor(&block)
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 |
- (Object) define_trait(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.
69 70 71 |
# File 'lib/factory_girl/definition.rb', line 69 def define_trait(trait) @defined_traits << trait end |
- (Object) definition_list
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 |
- (Object) inherit_traits(new_traits)
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 |
- (Object) overridable
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 |
- (Object) skip_create
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 |
- (Object) to_create(&block)
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 |