Sha256: 176bed9bbb83f1ba4a99ae0178e61a6e694be623f799a600eba5a50446677455

Contents?: true

Size: 812 Bytes

Versions: 1

Compression:

Stored size: 812 Bytes

Contents

module CanTango::Ability
  module Helper
    module Masquerade
      def masquerading?
        candidate.respond_to?(:masquerading?) && candidate.masquerading? && !masquerading_off?
      end
      alias_method :masquerade?, :masquerading?

      def masquerade_user?
        candidate.respond_to?(:active_user) && masquerading? && !masquerading_off?
      end

      def masquerade_account?
        candidate.respond_to?(:active_account) && masquerading? && !masquerading_off?
      end

      def masquerading_off?
        options[:masquerade] == false
      end
      alias_method :masquerade_off?, :masquerading_off?
      
      def subject
        return candidate.active_user if masquerade_user?
        return candidate.active_account if masquerade_account?
        candidate
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cantango-masquerade-0.1.3.2 lib/cantango/masquerade/ability/helper/masquerade.rb