reactive-ruby 0.7.15 → 0.7.16

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7e948fb3518db4028cc39e28dca45a3f13271aef
4
- data.tar.gz: 6d4e11a9c0bbb3d14ab9eb19aa48118e9c0048ba
3
+ metadata.gz: 62be457a5e6af8f6d9256a011861d1e3d24b6af4
4
+ data.tar.gz: e157fb2ff874e37b04298478da4f82081c07b616
5
5
  SHA512:
6
- metadata.gz: e4fa07962b7800a637c7222b5dc43957e04760e5fa6b7a366dd8cc2a451da92da8b6d2224673684c499d6f393f420351d18b768f8ca3f89758b3e8f77bc2909f
7
- data.tar.gz: 7c70da041fd31ccdb8b7ee003a621c4581a706035b6213f426f2007aba6275cc0d28349df21cf07f184d346d059b265500819e327dbb6e6761acba5e47edfbf7
6
+ metadata.gz: dde88af3a00a5718e5059fb710506098dcf5ca34389bed3007773f51f30067a2e600ce2ee2d07246c262b661460ec6a55da734bedeaaf3069dde9c35bfabd7ab
7
+ data.tar.gz: ce17d4836b267ea0db712a7b684fa14d492c8fdad81472db749ae21a051c11d6c3743ea959e8a3c74bf075f2147d6a6298182003b70c32a1c99797b315017031
@@ -6,11 +6,9 @@ begin
6
6
  class ActionController::Base
7
7
 
8
8
  def render_component(*args)
9
- component_name = ((args[0].is_a? Hash) || args.empty?) ? params[:action].camelize : args.shift
10
- controller = params[:controller].camelize
11
- rails_react_variables = (args[0].is_a? Hash) ? args[0] : {}
12
- @render_params = {component_name: component_name, controller: controller, render_params: rails_react_variables}
13
- render inline: "<%= react_component 'React.TopLevelRailsComponent', @render_params, { prerender: !params[:no_prerender] } %>", layout: 'application'
9
+ @component_name = ((args[0].is_a? Hash) || args.empty?) ? params[:action].camelize : args.shift
10
+ @render_params = (args[0].is_a? Hash) ? args[0] : {}
11
+ render inline: "<%= react_component @component_name, @render_params, { prerender: !params[:no_prerender] } %>", layout: 'application'
14
12
  end
15
13
 
16
14
  end
@@ -30,11 +28,13 @@ begin
30
28
  alias_method :pre_opal_react_component, :react_component
31
29
 
32
30
  def react_component(name, props = {}, render_options={}, &block)
31
+ props = {render_params: props, component_name: name, controller: self.controller.class.name}
32
+ name = 'React.TopLevelRailsComponent'
33
33
  if render_options[:prerender]
34
34
  render_options[:prerender] = {render_options[:prerender] => true} unless render_options[:prerender].is_a? Hash
35
35
  existing_context_initializer = render_options[:prerender][:context_initializer]
36
36
  render_options[:prerender][:context_initializer] = lambda do |ctx|
37
- React::IsomorphicHelpers.load_context(ctx, self.controller)
37
+ React::IsomorphicHelpers.load_context(ctx, self.controller, props[:component_name])
38
38
  existing_context_initializer.call ctx if existing_context_initializer
39
39
  end
40
40
 
@@ -8,17 +8,17 @@ module React
8
8
 
9
9
  if RUBY_ENGINE != 'opal'
10
10
 
11
- def self.load_context(ctx, controller)
12
- puts "************************** React Server Context Initialized *********************************************"
13
- @context = Context.new("#{controller.object_id}-#{Time.now.to_i}", ctx, controller)
11
+ def self.load_context(ctx, controller, name = nil)
12
+ puts "************************** React Server Context Initialized #{name} *********************************************"
13
+ @context = Context.new("#{controller.object_id}-#{Time.now.to_i}", ctx, controller, name)
14
14
  end
15
15
 
16
16
  else
17
17
 
18
- def self.load_context(unique_id = nil) # can be called on the client to force re-initialization for testing purposes
18
+ def self.load_context(unique_id = nil, name = nil) # can be called on the client to force re-initialization for testing purposes
19
19
  if !unique_id or !@context or @context.unique_id != unique_id
20
20
  if on_opal_server?
21
- message = "************************ React Prerendering Context Initialized ***********************"
21
+ message = "************************ React Prerendering Context Initialized #{name} ***********************"
22
22
  else
23
23
  message = "************************ React Browser Context Initialized ****************************"
24
24
  end
@@ -103,13 +103,13 @@ module React
103
103
  @prerender_footer_blocks ||= []
104
104
  end
105
105
 
106
- def initialize(unique_id, ctx = nil, controller = nil)
106
+ def initialize(unique_id, ctx = nil, controller = nil, name = nil)
107
107
  @unique_id = unique_id
108
108
  if RUBY_ENGINE != 'opal'
109
109
  @controller = controller
110
110
  @ctx = ctx
111
111
  ctx["ServerSideIsomorphicMethods"] = self
112
- send_to_opal(:load_context, @unique_id)
112
+ send_to_opal(:load_context, @unique_id, name)
113
113
  end
114
114
  self.class.before_first_mount_blocks.each { |block| block.call(self) }
115
115
  end
@@ -125,7 +125,7 @@ module React
125
125
  @ctx.eval(Opal::Processor.load_asset_code(::Rails.application.assets, 'components')) rescue nil
126
126
  raise "No opal-react components found in the components.rb file" unless @ctx.eval('Opal.React')
127
127
  end
128
- @ctx.eval("Opal.React.IsomorphicHelpers.$#{method}(#{args.join(', ')})")
128
+ @ctx.eval("Opal.React.IsomorphicHelpers.$#{method}(#{args.collect { |arg| "'#{arg}'"}.join(', ')})")
129
129
  end
130
130
  end
131
131
 
@@ -1,3 +1,3 @@
1
1
  module React
2
- VERSION = "0.7.15"
2
+ VERSION = "0.7.16"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reactive-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.15
4
+ version: 0.7.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Chang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-04 00:00:00.000000000 Z
11
+ date: 2015-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opal