Module: CanTango::Api::UserAccount::Ability::AbilityAccount

Defined in:
lib/cantango/api/user_account/ability.rb

Class Method Summary collapse

Class Method Details

.guestObject



37
38
39
40
41
42
# File 'lib/cantango/api/user_account/ability.rb', line 37

def self.guest
   = CanTango.config.guest.

  raise "You must set the guest_account to a Proc or lambda in CanTango.config" if !
  .respond_to?(:call) ? .call : 
end

.is_account?(account) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/cantango/api/user_account/ability.rb', line 33

def self.is_account? 
  ::CanTango.config.user_accounts.registered_class? .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. obj
  return obj if AbilityAccount.is_account?(obj)
  return (obj.send(:account)) if obj.respond_to?(:account)
  guest
end