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

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

Class Method Summary collapse

Class Method Details

.guestObject



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

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)


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

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



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

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