Sha256: 8d3c572dcb538d1605ba572013e8054a2f5d9553b877481a629ff16345fef9de
Contents?: true
Size: 756 Bytes
Versions: 1
Compression:
Stored size: 756 Bytes
Contents
module Gollum::Auth class InvalidUserError < StandardError end class User include ActiveModel::Model attr_accessor :username, :password, :name, :email validates_presence_of :username, :password, :name, :email validates_format_of :username, with: /\A[\w\.-]+\Z/ class << self def find(username) all.select { |u| u.username == username }.first end def all @all ||= [] end end def save! save ? self : raise(InvalidUserError, error_message) end def save (self.class.all << self; self) if valid? end def valid_password?(other) password == other end private def error_message errors.full_messages.join(', ') end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gollum-auth-0.5.0 | lib/gollum/auth/user.rb |