Sha256: a78581ccdb42271ea9fe8911ff6796b4b93f2a9dcf15af1256ce12973f13ec6b
Contents?: true
Size: 693 Bytes
Versions: 5
Compression:
Stored size: 693 Bytes
Contents
module CanTango::Api::Masquerade module User attr_reader :masquerading, :active_user def masquerade_as user raise "Must be a registered type of user, was: #{user}" unless valid_user? user @masquerading = true user = user.kind_of?(String) ? ::User.find(user) : user @active_user = user end def stop_masquerade @active_user, @masquerading = nil, nil end def masquerading? !@masquerading.nil? end alias_method :masquerade?, :masquerading? private def valid_user? user registered_users.registered_class?(user.class) end def registered_users CanTango.config.users end end end
Version data entries
5 entries across 5 versions & 1 rubygems