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
12
# File 'lib/factory_girl/trait.rb', line 5

def initialize(name, &block) #:nodoc:
  @name = name
  @block = block
  @definition = Definition.new

  proxy = FactoryGirl::DefinitionProxy.new(@definition)
  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

#==(other) ⇒ Object



21
22
23
24
# File 'lib/factory_girl/trait.rb', line 21

def ==(other)
  name == other.name &&
    block == other.block
end

#namesObject



17
18
19
# File 'lib/factory_girl/trait.rb', line 17

def names
  [@name]
end