Class: React::TopLevelRailsComponent
Instance Attribute Summary
#waiting_on_resources
Class Method Summary
collapse
Instance Method Summary
collapse
#_render_wrapper, #component_did_catch, #component_did_mount, #component_did_update, #component_will_mount, #component_will_receive_props, #component_will_unmount, #component_will_update, #define_state, deprecation_warning, #deprecation_warning, #emit, included, #initialize, #set_state_synchronously?, #update_react_js_state, #watch
Class Method Details
.search_path ⇒ Object
5
6
7
|
# File 'lib/rails-helpers/top_level_rails_component.rb', line 5
def self.search_path
@search_path ||= [Object]
end
|
Instance Method Details
17
18
19
|
# File 'lib/rails-helpers/top_level_rails_component.rb', line 17
def render
top_level_render
end
|
#top_level_render ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/rails-helpers/top_level_rails_component.rb', line 21
def top_level_render
paths_searched = []
component = nil
if params.component_name.start_with?('::')
paths_searched << params.component_name
component = begin
Object.const_get(params.component_name)
rescue NameError
nil
end
else
self.class.search_path.each do |scope|
paths_searched << "#{scope.name}::#{params.controller}::#{params.component_name}"
component = begin
scope.const_get(params.controller, false).const_get(params.component_name, false)
rescue NameError
nil
end
break if component != nil
end
unless component
self.class.search_path.each do |scope|
paths_searched << "#{scope.name}::#{params.component_name}"
component = begin
scope.const_get(params.component_name, false)
rescue NameError
nil
end
break if component != nil
end
end
end
return React::RenderingContext.render(component, params.render_params) if component && component.method_defined?(:render)
raise "Could not find component class '#{params.component_name}' for params.controller '#{params.controller}' in any component directory. Tried [#{paths_searched.join(", ")}]"
end
|