accounts_client 0.2.27 → 0.2.28
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/app/models/padma_account.rb +11 -0
- data/app/models/padma_user.rb +1 -1
- data/lib/accounts/belongs_to_account.rb +1 -12
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e155d578c4af832b80e36763cc48c209e35c6b4b
|
4
|
+
data.tar.gz: 634f81f73e24a11e88606c0287efd9e0bc961c5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e13fdaac7c3ec88a11b465385c3e659113a4f314a2a9a657d1cd5740b707c8750ea174645072137a2d3a4c02b63ed7a43747718de2c5e70cd5dd8f5a6df19cfe
|
7
|
+
data.tar.gz: 144278a34bf14ae8a9b63d4c3d08ff7134ec4fbafff4c8bba68b494bc723581047ea3bb9293b9e83399fd85b1e443c23b1772c07506bf8ca30ebdf5423b3a188
|
data/app/models/padma_account.rb
CHANGED
@@ -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
|
|
data/app/models/padma_user.rb
CHANGED
@@ -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.
|
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 =
|
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
|