Module: CanTango::Api::User::Ability::AbilityUser

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

Class Method Summary collapse

Class Method Details

.guestObject



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

def self.guest
  user = CanTango.config.guest.user

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

.is_user?(user) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/cantango/api/user/ability.rb', line 32

def self.is_user? user
  ::CanTango.config.users.registered_class? user.class
end

.resolve_user(obj) ⇒ Object

test if current_xxx actually returns an account and not a user instance! if so call the #user method on the account



26
27
28
29
30
# File 'lib/cantango/api/user/ability.rb', line 26

def self.resolve_user obj
  return obj if is_user?(obj)
  return resolve_user(obj.send(:user)) if obj.respond_to? :user
  guest
end