Sha256: 5e3fb73e68940c977e8016bd319ece789736446ae0e4b5fb00fc73ddf9a63434

Contents?: true

Size: 720 Bytes

Versions: 4

Compression:

Stored size: 720 Bytes

Contents

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

      def self.included(clazz)
        CanTango.config.users.register_user clazz
      end

      def active_user
        @active_user || self
      end

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

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

      protected

      include CanTango::Api::Common

      def ability opts = {}
        create_ability active_user, 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/user.rb
cantango-api-0.1.2 lib/cantango/api/model/user.rb
cantango-api-0.1.1 lib/cantango/api/model/user.rb
cantango-api-0.1.0 lib/cantango/api/model/user.rb