consul 0.11.1 → 0.11.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of consul might be problematic. Click here for more details.

data/README.md CHANGED
@@ -614,7 +614,7 @@ In such cases your model should simply skip authorization and assume that all us
614
614
  class UserReport
615
615
 
616
616
  def data
617
- accessible_users = Power.current.present? Power.current.users || User
617
+ accessible_users = Power.current.present? ? Power.current.users : User
618
618
  accessible_users.collect do |user|
619
619
  [user.name, user.email, user.income]
620
620
  end
@@ -74,15 +74,19 @@ module Consul
74
74
  end
75
75
  end
76
76
 
77
- def context_count_name(name)
78
- "#{name}_context_count"
79
- end
80
-
81
77
  def power_ids_name(name)
82
78
  "#{name.to_s.singularize}_ids"
83
79
  end
84
80
 
85
- attr_accessor :current
81
+ THREAD_KEY = :'Power.current'
82
+
83
+ def current
84
+ Thread.current[THREAD_KEY]
85
+ end
86
+
87
+ def current=(power)
88
+ Thread.current[THREAD_KEY] = power
89
+ end
86
90
 
87
91
  def with_power(inner_power, &block)
88
92
  unless inner_power.is_a?(self) || inner_power.nil?
@@ -1,3 +1,3 @@
1
1
  module Consul
2
- VERSION = '0.11.1'
2
+ VERSION = '0.11.2'
3
3
  end
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- consul (0.11.0)
4
+ consul (0.11.1)
5
5
  edge_rider
6
6
  memoizer
7
7
  rails
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- consul (0.11.0)
4
+ consul (0.11.1)
5
5
  edge_rider
6
6
  memoizer
7
7
  rails
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- consul (0.11.0)
4
+ consul (0.11.1)
5
5
  edge_rider
6
6
  memoizer
7
7
  rails
@@ -1,4 +1,5 @@
1
1
  require 'spec_helper'
2
+ require 'thread'
2
3
 
3
4
  describe Consul::Power do
4
5
 
@@ -458,6 +459,17 @@ describe Consul::Power do
458
459
 
459
460
  end
460
461
 
462
+ describe '.current=' do
463
+
464
+ it 'should set the given Power for the current thread only' do
465
+ Thread.new do
466
+ Power.current = 'some power'
467
+ end.join
468
+ Power.current.should be_nil
469
+ end
470
+
471
+ end
472
+
461
473
  describe '.with_power' do
462
474
 
463
475
  it 'should provide the given power as current power for the duration of the block' do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: consul
3
3
  version: !ruby/object:Gem::Version
4
- hash: 49
4
+ hash: 55
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 11
9
- - 1
10
- version: 0.11.1
9
+ - 2
10
+ version: 0.11.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Henning Koch
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2014-02-20 00:00:00 +01:00
18
+ date: 2014-03-26 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency