Sha256: 5410d7622b62d88edbfe84f4230b6a5d1b600f2e29aabd69310cfc50fa6c909d

Contents?: true

Size: 652 Bytes

Versions: 2

Compression:

Stored size: 652 Bytes

Contents

module CanTango::Api
  module Scope
    module User
      def scope_user scope, options = {}, &block
        user = scoped_user(scope)
        ab_scope = user_ability_scope(user, options)
        yield ab_scope if block
        ab_scope
      end
      alias_method :user_scope, :scope_user

      def real_user scope, options = {}, &block
        scope_user scope, options.merge(:masquerade => false), &block
      end

      protected

      def user_ability_scope user, options = {}
        CanTango::Ability::Scope.new user_ability(user, options)
      end

      def scoped_user scope
        send(:"current_#{scope}")
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cantango-api-0.1.1 lib/cantango/api/scope/user.rb
cantango-api-0.1.0 lib/cantango/api/scope/user.rb