Module: TinyCore::Has::Accounts::InstanceMethods

Defined in:
lib/tiny_core/has/accounts.rb

Instance Method Summary collapse

Instance Method Details

#set_role_for_account(account, role) ⇒ Object



24
25
26
# File 'lib/tiny_core/has/accounts.rb', line 24

def (, role)
  ().update_attribute(:role, role)
end

#shares_accounts_with?(user) ⇒ Boolean

Returns:

  • (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 ()
  update_attribute(:current_account_id, .id)
end

#user_account_for(account) ⇒ Object



28
29
30
# File 'lib/tiny_core/has/accounts.rb', line 28

def ()
  UserAccount.(self.id, .id)
end