rails_current 1.6.2 → 1.7.0

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.
data/lib/rails_current.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Current
4
4
  def Current.version
5
- '1.6.2'
5
+ '1.7.0'
6
6
  end
7
7
 
8
8
  def Current.dependencies
@@ -22,7 +22,6 @@ module Current
22
22
  require(lib)
23
23
  end
24
24
 
25
-
26
25
  def Current.data
27
26
  Thread.current[:current] ||= Map.new
28
27
  end
@@ -188,7 +187,7 @@ module Current
188
187
  #controller.send(:initialize_template_class, response)
189
188
  #controller.send(:assign_shortcuts, request, response)
190
189
  controller.send(:default_url_options).merge!(default_url_options)
191
- controller
190
+ Current.proxy_for(controller)
192
191
  end
193
192
  end
194
193
 
@@ -206,6 +205,24 @@ module Current
206
205
  block.call()
207
206
  end
208
207
  end
208
+
209
+ class BlankSlate
210
+ instance_methods.each{|m| undef_method(m) unless m.to_s =~ /^__|object_id/}
211
+ end
212
+
213
+ class Proxy < BlankSlate
214
+ def initialize(object)
215
+ @object = object
216
+ end
217
+
218
+ def method_missing(method, *args, &block)
219
+ @object.__send__(method, *args, &block)
220
+ end
221
+ end
222
+
223
+ def Current.proxy_for(object)
224
+ Proxy.new(object)
225
+ end
209
226
  end
210
227
 
211
228
  def Current(*args, &block)
@@ -230,8 +247,8 @@ if defined?(Rails)
230
247
  ::ActionController::Base.module_eval do
231
248
  prepend_before_filter do |controller|
232
249
  Current.clear
233
- Current.controller = controller
234
- Current.action = controller.send(:action_name)
250
+ Current.controller = Current.proxy_for(controller)
251
+ Current.action = controller ? controller.send(:action_name) : nil
235
252
  end
236
253
 
237
254
  extend Current
@@ -3,7 +3,7 @@
3
3
 
4
4
  Gem::Specification::new do |spec|
5
5
  spec.name = "rails_current"
6
- spec.version = "1.6.2"
6
+ spec.version = "1.7.0"
7
7
  spec.platform = Gem::Platform::RUBY
8
8
  spec.summary = "rails_current"
9
9
  spec.description = "description: rails_current kicks the ass"
@@ -147,9 +147,9 @@ Testing Current do
147
147
 
148
148
  ##
149
149
  #
150
- test 'that loading Current into an old skool rails app creates Current.user and Current.controller' do
150
+ test 'that loading Current into an old skool rails app creates Current.user and Current.controller and Current.action' do
151
151
  mock_rails! do
152
- assert{ Current.attributes =~ {:user => nil, :controller => nil} }
152
+ assert{ Current.attributes =~ {:user => nil, :controller => nil, :action => nil} }
153
153
 
154
154
  assert do
155
155
  Current.user = :user
@@ -168,7 +168,7 @@ Testing Current do
168
168
  #
169
169
  test 'that loading Current into a new skool rails app creates Current.user and Current.controller' do
170
170
  mock_rails_engine! do
171
- assert{ Current.attributes =~ {:user => nil, :controller => nil} }
171
+ assert{ Current.attributes =~ {:user => nil, :controller => nil, :action => nil} }
172
172
 
173
173
  assert{ $before_initialize_called }
174
174
  assert{ $prepend_before_filter_called }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_current
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.2
4
+ version: 1.7.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-09 00:00:00.000000000 Z
12
+ date: 2012-06-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: map
@@ -59,7 +59,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
59
59
  version: '0'
60
60
  requirements: []
61
61
  rubyforge_project: codeforpeople
62
- rubygems_version: 1.8.24
62
+ rubygems_version: 1.8.23
63
63
  signing_key:
64
64
  specification_version: 3
65
65
  summary: rails_current