public
Rubygem
Description: Liquid markup language. Save, customer facing template language for flexible web apps.
Homepage: http://www.liquidmarkup.org
Clone URL: git://github.com/tobi/liquid.git
Click here to lend your support to: liquid and make a donation at www.pledgie.com !
Make before_method work more like method_missing
Tobias Lütke (author)
Thu May 08 14:22:07 -0700 2008
commit  ed75a6d948a12fae73430e3df59d226263f5bf6b
tree    7e8f38af9f9ed61a1fdb9270da33498d1a21960b
parent  63f9a05223070337021164eabc06059bfafd20d9
...
28
29
30
31
32
33
34
 
 
 
 
 
 
35
36
37
...
28
29
30
 
 
 
 
31
32
33
34
35
36
37
38
39
0
@@ -28,10 +28,12 @@ module Liquid
0
     end
0
     
0
     # called by liquid to invoke a drop
0
- def invoke_drop(method)
0
- result = before_method(method)
0
- result ||= send(method.to_sym) if self.class.public_instance_methods.include?(method.to_s)
0
- result
0
+ def invoke_drop(method)
0
+ if self.class.public_instance_methods.include?(method.to_s)
0
+ send(method.to_sym)
0
+ else
0
+ before_method(method)
0
+ end
0
     end
0
     
0
     def has_key?(name)
...
62
63
64
65
 
 
 
 
66
67
68
69
70
71
 
72
73
74
...
147
148
149
 
 
 
 
150
151
152
...
62
63
64
 
65
66
67
68
69
70
71
72
73
 
74
75
76
77
...
150
151
152
153
154
155
156
157
158
159
0
@@ -62,13 +62,16 @@ class ProductDrop < Liquid::Drop
0
 end
0
 
0
 class EnumerableDrop < Liquid::Drop
0
- include Enumerable
0
+
0
+ def size
0
+ 3
0
+ end
0
   
0
   def each
0
     yield 1
0
     yield 2
0
     yield 3
0
- end
0
+ end
0
 end
0
 
0
 
0
@@ -147,6 +150,10 @@ class DropsTest < Test::Unit::TestCase
0
   def test_enumerable_drop
0
     assert_equal '123', Liquid::Template.parse( '{% for c in collection %}{{c}}{% endfor %}').render('collection' => EnumerableDrop.new)
0
   end
0
+
0
+ def test_enumerable_drop_size
0
+ assert_equal '3', Liquid::Template.parse( '{{collection.size}}').render('collection' => EnumerableDrop.new)
0
+ end
0
   
0
   
0
   

Comments

    No one has commented yet.