Sha256: 387e05451cdb68ddb30d7a1155d9fa3680d5c75f4539896134d15046753f56d5
Contents?: true
Size: 954 Bytes
Versions: 13
Compression:
Stored size: 954 Bytes
Contents
module CanTango module Api module User module Ability def user_ability user, options = {} @current_ability ||= create_ability(user, ability_options.merge(options)) end def current_ability user_type = :user user_ability get_ability_user(user_type) end protected include CanTango::Api::Common def get_ability_user user_type user_meth = :"current_#{user_type}" return AbilityUser.guest if !respond_to?(user_meth) user = send user_meth user ? user : AbilityUser.guest end module AbilityUser 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 end include CanTango::Api::Options end end end end
Version data entries
13 entries across 13 versions & 1 rubygems