Sha256: 9893f0a558de2729ec573fd6a2ea324883c33383d8c38e6fb83bdc03b69c5e2b

Contents?: true

Size: 702 Bytes

Versions: 2

Compression:

Stored size: 702 Bytes

Contents

module CanTango::Api
  module Scope
    module User
      include CanTango::Api::Ability::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::Scope::Ability.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.3 lib/cantango/api/scope/user.rb
cantango-api-0.1.2 lib/cantango/api/scope/user.rb