Class: FactoryGirl::Trait

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nameObject (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

#attributesObject



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

#namesObject



25
26
27
# File 'lib/factory_girl/trait.rb', line 25

def names
  [@name]
end