@@ -27,7 +27,9 @@ def self.included(base)
2727 base . extend ( ClassMethods )
2828
2929 if base . name
30- parent = base . name . split ( "::" ) . inject ( [ Module ] ) { |nesting , next_const | nesting + [ nesting . last . const_get ( next_const ) ] } [ -2 ]
30+ parent = base . name . split ( "::" ) . inject ( [ Module ] ) { |nesting , next_const |
31+ nesting + [ nesting . last . const_get ( next_const ) ]
32+ } [ -2 ]
3133
3234 class << parent
3335 def method_missing ( n , *args , &block )
@@ -59,7 +61,8 @@ def render
5961 end unless method_defined? ( :render )
6062
6163 def deprecated_params_method ( name , *args , &block )
62- self . class . deprecation_warning "Direct access to param `#{ name } `. Use `params.#{ name } ` instead."
64+ notice = "Direct access to param `#{ name } `. Use `params.#{ name } ` instead."
65+ self . class . deprecation_warning ( notice )
6366 params . send ( name , *args , &block )
6467 end
6568
@@ -108,13 +111,13 @@ def refs
108111 end
109112
110113 def state
111- #raise "No native ReactComponent associated" unless @native
112114 @state_wrapper ||= StateWrapper . new ( @native , self )
113115 end
114116
115117 def update_react_js_state ( object , name , value )
116118 if object
117- set_state ( { "***_state_updated_at-***" => Time . now . to_f , "#{ object . class . to_s +'.' unless object == self } #{ name } " => value } )
119+ set_state ( { "***_state_updated_at-***" => Time . now . to_f ,
120+ "#{ object . class . to_s +'.' unless object == self } #{ name } " => value } )
118121 else
119122 set_state ( { name => value } )
120123 end rescue nil
@@ -128,7 +131,9 @@ def component_will_mount
128131 IsomorphicHelpers . load_context ( true ) if IsomorphicHelpers . on_opal_client?
129132 set_state! initial_state if initial_state
130133 State . initialize_states ( self , initial_state )
131- State . set_state_context_to ( self ) { self . run_callback ( :before_mount ) }
134+ State . set_state_context_to ( self ) do
135+ self . run_callback ( :before_mount )
136+ end
132137 rescue Exception => e
133138 self . class . process_exception ( e , self )
134139 end
@@ -143,9 +148,12 @@ def component_did_mount
143148 end
144149
145150 def component_will_receive_props ( next_props )
146- # need to rethink how this works in opal-react, or if its actually that useful within the react.rb environment
147- # for now we are just using it to clear processed_params
148- State . set_state_context_to ( self ) { self . run_callback ( :before_receive_props , Hash . new ( next_props ) ) }
151+ # need to rethink how this works in opal-react, or if its actually that
152+ # useful within the react.rb environment for now we are just using it to
153+ # clear processed_params
154+ State . set_state_context_to ( self ) do
155+ self . run_callback ( :before_receive_props , Hash . new ( next_props ) )
156+ end
149157 rescue Exception => e
150158 self . class . process_exception ( e , self )
151159 end
@@ -177,7 +185,9 @@ def should_component_update?(next_props, next_state)
177185 end
178186
179187 def component_will_update ( next_props , next_state )
180- State . set_state_context_to ( self ) { self . run_callback ( :before_update , Hash . new ( next_props ) , Hash . new ( next_state ) ) }
188+ State . set_state_context_to ( self ) do
189+ self . run_callback ( :before_update , next_props , Hash . new ( next_state ) )
190+ end
181191 rescue Exception => e
182192 self . class . process_exception ( e , self )
183193 end
@@ -210,7 +220,9 @@ def p(*args, &block)
210220
211221 def component? ( name )
212222 name_list = name . split ( "::" )
213- scope_list = self . class . name . split ( "::" ) . inject ( [ Module ] ) { |nesting , next_const | nesting + [ nesting . last . const_get ( next_const ) ] } . reverse
223+ scope_list = self . class . name . split ( "::" ) . inject ( [ Module ] ) do |nesting , next_const |
224+ nesting + [ nesting . last . const_get ( next_const ) ]
225+ end . reverse
214226 scope_list . each do |scope |
215227 component = name_list . inject ( scope ) do |scope , class_name |
216228 scope . const_get ( class_name )
@@ -221,7 +233,9 @@ def component?(name)
221233 end
222234
223235 def method_missing ( n , *args , &block )
224- return props [ n ] if props . key? n # TODO deprecate and remove - done so that params shadow tags, no longer needed
236+ # TODO deprecate and remove - done so that params shadow tags, no longer
237+ # needed
238+ return props [ n ] if props . key? ( n )
225239 name = n
226240 if name =~ /_as_node$/
227241 node_only = true
@@ -254,7 +268,11 @@ def define_state(*args, &block)
254268
255269 def _render_wrapper
256270 State . set_state_context_to ( self ) do
257- RenderingContext . render ( nil ) { render || "" } . tap { |element | @waiting_on_resources = element . waiting_on_resources if element . respond_to? :waiting_on_resources }
271+ RenderingContext . render ( nil ) { render || "" } . tap do |element |
272+ if element . respond_to? ( :waiting_on_resources )
273+ @waiting_on_resources = element . waiting_on_resources
274+ end
275+ end
258276 end
259277 rescue Exception => e
260278 self . class . process_exception ( e , self )
0 commit comments