Class: FactoryGirl::Trait
- Inherits:
-
Object
- Object
- FactoryGirl::Trait
- Defined in:
- lib/factory_girl/trait.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #add_callback(name, &block) ⇒ Object
- #attributes ⇒ Object
- #define_attribute(attribute) ⇒ Object
-
#initialize(name, &block) ⇒ Trait
constructor
:nodoc:.
- #names ⇒ Object
Constructor Details
#initialize(name, &block) ⇒ Trait
:nodoc:
5 6 7 8 9 10 11 |
# File 'lib/factory_girl/trait.rb', line 5 def initialize(name, &block) #:nodoc: @name = name @attribute_list = AttributeList.new proxy = FactoryGirl::DefinitionProxy.new(self) proxy.instance_eval(&block) if block_given? end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/factory_girl/trait.rb', line 3 def name @name end |
Instance Method Details
#add_callback(name, &block) ⇒ Object
17 18 19 |
# File 'lib/factory_girl/trait.rb', line 17 def add_callback(name, &block) @attribute_list.add_callback(name, &block) end |
#attributes ⇒ Object
21 22 23 |
# File 'lib/factory_girl/trait.rb', line 21 def attributes @attribute_list.to_a end |
#define_attribute(attribute) ⇒ Object
13 14 15 |
# File 'lib/factory_girl/trait.rb', line 13 def define_attribute(attribute) @attribute_list.define_attribute(attribute) end |
#names ⇒ Object
25 26 27 |
# File 'lib/factory_girl/trait.rb', line 25 def names [@name] end |