Module: TinyCore::Has::Accounts::InstanceMethods
- Defined in:
- lib/tiny_core/has/accounts.rb
Instance Method Summary collapse
- #set_role_for_account(account, role) ⇒ Object
- #shares_accounts_with?(user) ⇒ Boolean
- #switch_to_account(account) ⇒ Object
- #user_account_for(account) ⇒ Object
Instance Method Details
#set_role_for_account(account, role) ⇒ Object
24 25 26 |
# File 'lib/tiny_core/has/accounts.rb', line 24 def set_role_for_account(account, role) user_account_for(account).update_attribute(:role, role) end |
#shares_accounts_with?(user) ⇒ Boolean
32 33 34 35 |
# File 'lib/tiny_core/has/accounts.rb', line 32 def shares_accounts_with?(user) # This can probably be done more efficiently !(self.accounts & user.accounts).empty? end |
#switch_to_account(account) ⇒ Object
20 21 22 |
# File 'lib/tiny_core/has/accounts.rb', line 20 def switch_to_account(account) update_attribute(:current_account_id, account.id) end |
#user_account_for(account) ⇒ Object
28 29 30 |
# File 'lib/tiny_core/has/accounts.rb', line 28 def user_account_for(account) UserAccount.find_by_user_id_and_account_id(self.id, account.id) end |