@@ -23,56 +23,13 @@ def self.included(base)
2323 define_callback :before_update
2424 define_callback :after_update
2525 define_callback :before_unmount
26-
27- def deprecated_params_method ( name , *args , &block )
28- self . class . deprecation_warning "Direct access to param `#{ name } `. Use `params.#{ name } ` instead."
29- params . send ( name , *args , &block )
30- end
31-
32- def render
33- raise "no render defined"
34- end unless method_defined? ( :render )
35-
36- def children
37- nodes = [ `#{ @native } .props.children` ] . flatten
38- class << nodes
39- include Enumerable
40-
41- def to_n
42- self
43- end
44-
45- def each ( &block )
46- if block_given?
47- %x{
48- React.Children.forEach(#{ self . to_n } , function(context){
49- #{ block . call ( React ::Element . new ( `context` ) ) }
50- })
51- }
52- nil
53- else
54- Enumerator . new ( `React.Children.count(#{ self . to_n } )` ) do |y |
55- %x{
56- React.Children.forEach(#{ self . to_n } , function(context){
57- #{ y << React ::Element . new ( `context` ) }
58- })
59- }
60- end
61- end
62- end
63- end
64-
65- nodes
66- end
67-
6826 end
6927 base . extend ( ClassMethods )
7028
7129 if base . name
7230 parent = base . name . split ( "::" ) . inject ( [ Module ] ) { |nesting , next_const | nesting + [ nesting . last . const_get ( next_const ) ] } [ -2 ]
7331
7432 class << parent
75-
7633 def method_missing ( n , *args , &block )
7734 name = n
7835 if name =~ /_as_node$/
@@ -89,7 +46,6 @@ def method_missing(n, *args, &block)
8946 end
9047 RenderingContext . build_or_render ( node_only , name , *args , &block )
9148 end
92-
9349 end
9450 end
9551 end
@@ -98,6 +54,47 @@ def initialize(native_element)
9854 @native = native_element
9955 end
10056
57+ def render
58+ raise "no render defined"
59+ end unless method_defined? ( :render )
60+
61+ def deprecated_params_method ( name , *args , &block )
62+ self . class . deprecation_warning "Direct access to param `#{ name } `. Use `params.#{ name } ` instead."
63+ params . send ( name , *args , &block )
64+ end
65+
66+ def children
67+ nodes = [ `#{ @native } .props.children` ] . flatten
68+ class << nodes
69+ include Enumerable
70+
71+ def to_n
72+ self
73+ end
74+
75+ def each ( &block )
76+ if block_given?
77+ %x{
78+ React.Children.forEach(#{ self . to_n } , function(context){
79+ #{ block . call ( React ::Element . new ( `context` ) ) }
80+ })
81+ }
82+ nil
83+ else
84+ Enumerator . new ( `React.Children.count(#{ self . to_n } )` ) do |y |
85+ %x{
86+ React.Children.forEach(#{ self . to_n } , function(context){
87+ #{ y << React ::Element . new ( `context` ) }
88+ })
89+ }
90+ end
91+ end
92+ end
93+ end
94+
95+ nodes
96+ end
97+
10198 def params
10299 @props_wrapper
103100 end
0 commit comments