reactive-router 0.7.8 → 0.7.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/reactive-router/router.rb +16 -22
- data/lib/reactive-router/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7464c623e1e6a0ec3a9ed9ad5606dfdfb3b2574
|
4
|
+
data.tar.gz: 4a70b6f2c314855b5d94f8834dc2b45445ca86d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
48
|
-
@
|
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
|
-
|
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
|
-
|
60
|
+
method_name = opts[:as] || name
|
59
61
|
|
60
62
|
class << self
|
61
63
|
define_method method_name do
|
62
|
-
|
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
|
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.
|
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
|
|
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.
|
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-
|
11
|
+
date: 2015-10-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|