@api private
# File lib/factory_girl/evaluator.rb, line 49 def self.attribute_list AttributeList.new.tap do |list| attribute_lists.each do |attribute_list| list.apply_attributes attribute_list.to_a end end end
# File lib/factory_girl/evaluator.rb, line 57 def self.define_attribute(name, &block) define_method(name) do if @cached_attributes.key?(name) @cached_attributes[name] else @cached_attributes[name] = instance_exec(&block) end end end
# File lib/factory_girl/evaluator.rb, line 13 def initialize(build_strategy, overrides = {}) @build_strategy = build_strategy @overrides = overrides @cached_attributes = overrides @overrides.each do |name, value| singleton_class.define_attribute(name) { value } end end
# File lib/factory_girl/evaluator.rb, line 45 def __override_names__ @overrides.keys end
# File lib/factory_girl/evaluator.rb, line 23 def association(factory_name, *traits_and_overrides) overrides = traits_and_overrides.extract_options! strategy_override = overrides.fetch(:strategy) { :create } traits_and_overrides += [overrides.except(:strategy)] runner = FactoryRunner.new(factory_name, strategy_override, traits_and_overrides) @build_strategy.association(runner) end
# File lib/factory_girl/evaluator.rb, line 33 def instance=(object_instance) @instance = object_instance end
# File lib/factory_girl/evaluator.rb, line 37 def method_missing(method_name, *args, &block) if @instance.respond_to?(method_name) @instance.send(method_name, *args, &block) else SyntaxRunner.new.send(method_name, *args, &block) end end