Module: CanTango::Api::Ability::Account::AbilityAccount
- Defined in:
- lib/cantango/api/ability/account.rb
Class Method Summary collapse
- .guest ⇒ Object
- .is_account?(account) ⇒ Boolean
-
.resolve_account(obj) ⇒ Object
test if current_xxx actually returns an account and not a user instance! if so call the #account method on the user.
Class Method Details
.guest ⇒ Object
37 38 39 40 41 42 |
# File 'lib/cantango/api/ability/account.rb', line 37 def self.guest account = CanTango.config.guest.account raise "You must set the guest_account to a Proc or lambda in CanTango.config" if !account account.respond_to?(:call) ? account.call : account end |
.is_account?(account) ⇒ Boolean
33 34 35 |
# File 'lib/cantango/api/ability/account.rb', line 33 def self.is_account? account ::CanTango.config.accounts.registered_class? account.class end |
.resolve_account(obj) ⇒ Object
test if current_xxx actually returns an account and not a user instance! if so call the #account method on the user
27 28 29 30 31 |
# File 'lib/cantango/api/ability/account.rb', line 27 def self.resolve_account obj return obj if AbilityAccount.is_account?(obj) return resolve_account(obj.send(:account)) if obj.respond_to?(:account) guest end |