accounts_client 0.2.8 → 0.2.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/accounts/belongs_to_user.rb +11 -6
  2. metadata +2 -2
@@ -19,15 +19,20 @@ module Accounts
19
19
  # @option options [TrueClass] force_service_call - forces call to users-ws
20
20
  # @return [PadmaUser / PadmaUserDecorator]
21
21
  def user(options={})
22
- if self.padma_user.nil? || options[:force_service_call]
23
- self.padma_user = PadmaUser.find(username)
22
+ padma_user ||= Rails.cache.read([username,"padma_user"])
23
+
24
+ if padma_user.nil? || options[:force_service_call]
25
+ padma_user = PadmaUser.find(username)
26
+ if padma_user
27
+ Rails.cache.write([self,"padma"], padma_user, :expires_in => 5.minutes)
28
+ end
24
29
  end
25
- # TODO cache
26
- ret = padma_user
30
+
27
31
  if options[:decorated] && padma_user
28
- ret = PadmaUserDecorator.decorate(padma_user)
32
+ PadmaUserDecorator.decorate(padma_user)
33
+ else
34
+ padma_user
29
35
  end
30
- ret
31
36
  end
32
37
 
33
38
  private
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.8
4
+ version: 0.2.9
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: 2015-02-24 00:00:00.000000000 Z
12
+ date: 2015-03-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties