reactive-router 0.7.8 → 0.7.9

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: a4807bfc54a06c05e47632fce9506d66b40a39a4
4
- data.tar.gz: d0556c0657b4c6445fc5de28c927a2a058081531
3
+ metadata.gz: c7464c623e1e6a0ec3a9ed9ad5606dfdfb3b2574
4
+ data.tar.gz: 4a70b6f2c314855b5d94f8834dc2b45445ca86d1
5
5
  SHA512:
6
- metadata.gz: dae94468405923b8cf973ad4ec006deb82030122170694f8449cb949b4656c624aa2b71b7100df09fc0d647a498c0b64750315d38c0cf026eb15d4b1a952af68
7
- data.tar.gz: ad3033f9f71ee5fd01c1425fb1c3c9bd706e87c2b6a717fbd94159a5e24d1b3ce510c3401c578a5022953030f6378f829311004cf04f14dad44fc74fc7bf90c4
6
+ metadata.gz: 6f26f5372874c3c24bf7f70d5931ca79e66fc830fa728f715b3f12463f3735ef30c43a9f0386eac45816fd547246f5cef8b2ad025020151599b8160f5c2e4f9b
7
+ data.tar.gz: 0d9032cd9212fa186ac35da1ca2dbe3e328af3195039a26ff67a808df80f633949beced36826c649b4bcaf7ab8602dd98cd2c1462f814417a5502ffff0ee4290
@@ -44,8 +44,8 @@ module React
44
44
  React::RenderingContext.render("a", opts, &block).on(:click) { transition_to(to, params, query) }
45
45
  end
46
46
 
47
- def url_param_evaluators
48
- @url_param_evaluators ||= []
47
+ def url_param_methods
48
+ @url_param_methods ||= []
49
49
  end
50
50
 
51
51
  attr_accessor :evaluated_url_params
@@ -53,33 +53,28 @@ module React
53
53
 
54
54
  def router_param(name, opts = {}, &block)
55
55
 
56
- method_name = opts[:as] || name
56
+ # create a method visible both the instance and the class
57
+ # that gets passed the named router parameter (typically a db :id) and returns a
58
+ # meaningful value (typically a database record)
57
59
 
58
- url_param_evaluators << [name, block]
60
+ method_name = opts[:as] || name
59
61
 
60
62
  class << self
61
63
  define_method method_name do
62
- evaluated_url_params[name]
64
+ if @router_component
65
+ block.call @router_component.url_params[name]
66
+ else
67
+ raise "Call to #{self.name}.#{method_name} when #{self.name} is not mounted"
68
+ end
63
69
  end
64
70
  end
65
71
 
66
72
  define_method method_name do
67
- self.class.send(method_name)
73
+ self.class.send method_name
68
74
  end
69
75
 
70
76
  end
71
77
 
72
- def evaluate_new_params(params)
73
- url_param_evaluators.each do |name, block|
74
- begin
75
- evaluated_url_params[name] = block.call(params[name]) if params.has_key?(name) and current_url_params[name] != params[name]
76
- current_url_params[name] = params[name]
77
- rescue Exception => e
78
- log("failed to process router param #{name} (#{params[name]}): #{e}", :error)
79
- end
80
- end
81
- end
82
-
83
78
  end
84
79
 
85
80
  static_call_back "willTransitionTo" do |transition, params, query, callback|
@@ -128,14 +123,13 @@ module React
128
123
  optional_param :query
129
124
  optional_param :params
130
125
 
131
- def url_params(params)
132
- params[:params] || (params[:router_state] && params[:router_state][:params]) || {}
126
+ def url_params(params = params)
127
+ (params && (params[:params] || (params[:router_state] && params[:router_state][:params]))) || {}
133
128
  end
134
129
 
135
-
136
130
  def render
137
131
  if self.class.routing?
138
- self.class.evaluate_new_params url_params(params)
132
+ self.class.instance_variable_set(:@router_component, self) # this was done after mount, but I think it works here
139
133
  show
140
134
  elsif on_opal_server?
141
135
  self.class.routing!
@@ -183,7 +177,7 @@ module React
183
177
  }
184
178
  elsif respond_to? :show
185
179
  puts "after mount inside of ruby router #{self.object_id}, my class router is #{self.class.object_id}"
186
- self.class.instance_variable_set(:@router_component, self)
180
+ #self.class.instance_variable_set(:@router_component, self) # this was done here but was moved to the first render
187
181
  end
188
182
  end
189
183
 
@@ -1,3 +1,3 @@
1
1
  module ReactiveRouter
2
- VERSION = "0.7.8"
2
+ VERSION = "0.7.9"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reactive-router
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.8
4
+ version: 0.7.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam George
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-24 00:00:00.000000000 Z
11
+ date: 2015-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler