Module: Accounts::BelongsToUser
- Defined in:
- lib/accounts/belongs_to_user.rb
Instance Attribute Summary collapse
-
#padma_user ⇒ Object
Returns the value of attribute padma_user.
Class Method Summary collapse
Instance Method Summary collapse
-
#user(options = {}) ⇒ PadmaUser / PadmaUserDecorator
Returns associated user.
Instance Attribute Details
#padma_user ⇒ Object
Returns the value of attribute padma_user.
11 12 13 |
# File 'lib/accounts/belongs_to_user.rb', line 11 def padma_user @padma_user end |
Class Method Details
.included(base) ⇒ Object
7 8 9 |
# File 'lib/accounts/belongs_to_user.rb', line 7 def self.included(base) base.send(:validate, :padma_user_setted_correctly) end |
Instance Method Details
#user(options = {}) ⇒ PadmaUser / PadmaUserDecorator
Returns associated user.
user is stored in instance variable padma_user. This allows for it to be setted in a Mass-Load.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/accounts/belongs_to_user.rb', line 21 def user(={}) padma_user ||= Rails.cache.read([username,"padma_user"]) if padma_user.nil? || [:force_service_call] padma_user = PadmaUser.find(username) if padma_user Rails.cache.write([username,"padma_user"], padma_user, :expires_in => 5.minutes) end end if [:decorated] && padma_user PadmaUserDecorator.decorate(padma_user) else padma_user end end |