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 |
# File 'lib/accounts/belongs_to_user.rb', line 21 def user(={}) if self.padma_user.nil? || [:force_service_call] self.padma_user = PadmaUser.find(username) end # TODO cache ret = padma_user if [:decorated] && padma_user ret = PadmaUserDecorator.decorate(padma_user) end ret end |