Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Don't compile unless necessary
  • Loading branch information
joshuaclayton committed Jan 8, 2012
1 parent a022dda commit ac1df1d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/factory_girl/factory.rb
Expand Up @@ -13,6 +13,7 @@ def initialize(name, options = {}) #:nodoc:
@class_name = options[:class]
@default_strategy = options[:default_strategy]
@definition = Definition.new(@name)
@compiled = false

inherit_traits(options[:traits] || [])
end
Expand Down Expand Up @@ -83,9 +84,12 @@ def names
end

def compile
parent.defined_traits.each {|trait| define_trait(trait) }
parent.compile
@definition.compile
unless @compiled
parent.defined_traits.each {|trait| define_trait(trait) }
parent.compile
@definition.compile
@compiled = true
end
end

def with_traits(traits)
Expand Down

0 comments on commit ac1df1d

Please sign in to comment.