accounts_client 0.2.27 → 0.2.28

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: 02a6317fe59bd0d8df3b71cc5a3565d54237731d
4
- data.tar.gz: aa10d37d3b8608e637e5df9bd3b594ef813d0874
3
+ metadata.gz: e155d578c4af832b80e36763cc48c209e35c6b4b
4
+ data.tar.gz: 634f81f73e24a11e88606c0287efd9e0bc961c5a
5
5
  SHA512:
6
- metadata.gz: e31f78e293f256da5d1fc4f1106471a6093c4edebf2a74f18020f2b1ee46e5f6c67a95b574a7eb03beec3876a80aaef5f93e91dd1477f64be39c6a4c0c1063ad
7
- data.tar.gz: 7efdc47350c37c190bb311cfd4898cbc1fd14ed1b34f1346a198148b6b3eb096fcecf82f8a384f2f5ac2fbd0a365a2b47164094e9e660f84f9ba08d46d1002e0
6
+ metadata.gz: e13fdaac7c3ec88a11b465385c3e659113a4f314a2a9a657d1cd5740b707c8750ea174645072137a2d3a4c02b63ed7a43747718de2c5e70cd5dd8f5a6df19cfe
7
+ data.tar.gz: 144278a34bf14ae8a9b63d4c3d08ff7134ec4fbafff4c8bba68b494bc723581047ea3bb9293b9e83399fd85b1e443c23b1772c07506bf8ca30ebdf5423b3a188
@@ -72,6 +72,17 @@ class PadmaAccount < LogicalModel
72
72
 
73
73
  res
74
74
  end
75
+
76
+ def self.find_with_rails_cache(account_name)
77
+ pa = Rails.cache.read([account_name,"padma_account"])
78
+ if pa.nil?
79
+ pa = PadmaAccount.find(account_name)
80
+ if pa
81
+ Rails.cache.write([account_name,"padma_account"], pa, :expires_in => 5.minutes)
82
+ end
83
+ end
84
+ pa
85
+ end
75
86
 
76
87
  private
77
88
 
@@ -36,7 +36,7 @@ class PadmaUser < LogicalModel
36
36
  def current_account
37
37
  unless cached_current_account
38
38
  if self.current_account_name
39
- self.cached_current_account= PadmaAccount.find(self.current_account_name)
39
+ self.cached_current_account= PadmaAccount.find_with_rails_cache(self.current_account_name)
40
40
  end
41
41
  end
42
42
  cached_current_account
@@ -22,7 +22,7 @@ module Accounts
22
22
  # @return [PadmaAccount / PadmaAccountDecorator]
23
23
  def account(options={})
24
24
  if self.padma_account.nil? || options[:force_service_call]
25
- self.padma_account = get_account_from_padma(account_name)
25
+ self.padma_account = PadmaAccount.find_with_rails_cache(account_name)
26
26
  end
27
27
  ret = padma_account
28
28
  if options[:decorated] && padma_account
@@ -36,17 +36,6 @@ module Accounts
36
36
  end
37
37
 
38
38
  private
39
-
40
- def get_account_from_padma(account_name)
41
- pa = Rails.cache.read([account_name,"padma_account"])
42
- if pa.nil?
43
- pa = PadmaAccount.find(account_name)
44
- if pa
45
- Rails.cache.write([account_name,"padma_account"], pa, :expires_in => 5.minutes)
46
- end
47
- end
48
- pa
49
- end
50
39
 
51
40
  # If padma_account is setted with a PadmaAccount that doesn't match
52
41
  # account_id an exception will be raised
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: accounts_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.27
4
+ version: 0.2.28
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dwayne Macgowan