Sha256: 1960eb3407651d180ae75c5bc71c5971e412fb6a6bc04c97d6c7f9e10630bdfa

Contents?: true

Size: 721 Bytes

Versions: 22

Compression:

Stored size: 721 Bytes

Contents

module CanTango
  module Api
    module UserAccount
      module Scope

        def account_scope scope, options = {}, &block
          account = scoped_account(scope)
          ab_scope = account_ability_scope(account, options)
          yield ab_scope if block
          ab_scope
        end

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

        protected

        def account_ability_scope account, options = {}
          CanTango::Ability::Scope.new user_account_ability(account, options)
        end

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

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
cantango-0.8.5.1 lib/cantango/api/user_account/scope.rb
cantango-0.8.0 lib/cantango/api/user_account/scope.rb