Sha256: 5c8b8f97590e41befa47754f330220ff97efdb41e974043ffccbd3d69e5ee328

Contents?: true

Size: 681 Bytes

Versions: 19

Compression:

Stored size: 681 Bytes

Contents

module Saucy
  module User
    extend ActiveSupport::Concern

    included do
      attr_accessible :name, :project_ids, :email, :password
      has_many :memberships
      has_many :accounts, :through => :memberships
      has_many :permissions
      has_many :projects, :through => :permissions
      validates_presence_of :name
    end

    module InstanceMethods
      def admin_of?(account)
        memberships.exists?(:account_id => account.id, :admin => true)
      end

      def member_of?(account_or_project)
        account_or_project.has_member?(self)
      end
    end

    module ClassMethods
      def by_name
        order('users.name')
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
saasy-0.0.2.alpha3 lib/saucy/user.rb
saasy-0.0.2.alpha2 lib/saucy/user.rb
saasy-0.0.2.alpha1 lib/saucy/user.rb
saucy-0.10.0 lib/saucy/user.rb
saucy-0.9.1 lib/saucy/user.rb
saucy-0.9.0 lib/saucy/user.rb
saucy-0.8.5 lib/saucy/user.rb
saucy-0.8.4 lib/saucy/user.rb
saucy-0.8.3 lib/saucy/user.rb
saasy-0.0.1 lib/saucy/user.rb
saucy-0.8.2 lib/saucy/user.rb
saucy-0.8.1 lib/saucy/user.rb
saucy-0.8.0 lib/saucy/user.rb
saucy-0.7.3 lib/saucy/user.rb
saucy-0.7.2 lib/saucy/user.rb
saucy-0.7.1 lib/saucy/user.rb
saucy-0.7.0 lib/saucy/user.rb
saucy-0.6.1 lib/saucy/user.rb
saucy-0.6.0 lib/saucy/user.rb