Module: CanTango::Api::UserAccount::Ability::AbilityAccount
- Defined in:
- lib/cantango/api/user_account/ability.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/user_account/ability.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/user_account/ability.rb', line 33 def self.is_account? account ::CanTango.config.user_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/user_account/ability.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 |