public
Description: FixtureReplacement rails plugin (version 2 and on)
Homepage: http://replacefixtures.rubyforge.org/
Clone URL: git://github.com/smtlaissezfaire/fixturereplacement.git
Search Repo:
refactoring into delayed evaluation proc

git-svn-id: http://thmadb.com/public_svn/plugins/fixture_replacement2@332 
6dbbdfbd-06da-443d-8068-b1bdd22a71ef
smt (author)
Sun Mar 09 21:59:13 -0700 2008
commit  975addf30b17205ca218ae0acc6cd77a6f7fcbab
tree    9717db4eaca89c7766ed1aa33300b6b2ede7de19
parent  5c16b52168e61e1642b77b2db646ae070287d110
...
38
39
40
41
42
43
44
45
46
47
48
49
50
51
 
52
53
54
...
38
39
40
 
 
 
 
 
41
42
43
44
45
 
46
47
48
49
0
@@ -38,17 +38,12 @@
0
       end
0
     end
0
 
0
- def find_value_from_delayed_evaluation_proc(value)
0
- default_obj, params = value.call
0
- value = @caller.__send__("create_#{default_obj.fixture_name}", params)
0
- end
0
-
0
     def evaluate_possible_delayed_proc(value)
0
       case value
0
       when Array
0
         value.map! { |element| evaluate_possible_delayed_proc element }
0
       when ClassFactory.delayed_evaluation_proc
0
- find_value_from_delayed_evaluation_proc(value)
0
+ value.evaluate(@caller)
0
       else
0
         value
0
       end
...
2
3
4
5
 
 
 
 
 
 
6
...
2
3
4
 
5
6
7
8
9
10
11
0
@@ -2,6 +2,11 @@
0
   # This is here so that if someone (some how) assigns a proc
0
   # to an accessor on an ActiveRecord object, FixtureReplacement
0
   # won't get tripped up, and try to evaluate the proc.
0
- class DelayedEvaluationProc < Proc; end
0
+ class DelayedEvaluationProc < Proc
0
+ def evaluate(caller)
0
+ default_obj, params = self.call
0
+ return caller.__send__("create_#{default_obj.fixture_name}", params)
0
+ end
0
+ end
0
 end

Comments

    No one has commented yet.