Sha256: 62065d14a5a66e829599ba970be444f9d6f014e16a00749aed86e3780de4c2b3

Contents?: true

Size: 727 Bytes

Versions: 4

Compression:

Stored size: 727 Bytes

Contents

module CanTango::Api
  module Model
    module Account
      attr_writer :active_user, :active_account, :ability_class

      def self.included(clazz)
        CanTango.config.accounts.register_account clazz
      end

      def active_user
        return @active_user if  @active_user
        return send(:user) if respond_to? :user
        raise "No user could be found for account: #{self}"
      end

      def active_account
        @active_account || self
      end

      # from sugar-high or Active Support
      delegate :can?, :cannot?, :to => :ability

      protected
    
      include CanTango::Api::Common

      def ability opts = {}
        create_ability active_account, opts = {}
      end  
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cantango-api-0.1.3 lib/cantango/api/model/account.rb
cantango-api-0.1.2 lib/cantango/api/model/account.rb
cantango-api-0.1.1 lib/cantango/api/model/account.rb
cantango-api-0.1.0 lib/cantango/api/model/account.rb