Sha256: bfca5e5b9dcce41fc2cd66e0f5ab46fc20d0666f5a91b16536be4f871472b830
Contents?: true
Size: 1.26 KB
Versions: 5
Compression:
Stored size: 1.26 KB
Contents
module Symphonia module UserManagement extend ActiveSupport::Concern included do enum status: { active: 1, pending: 5, archived: 9 } scope :sorted, -> { order(:first_name, :last_name) } # validates :mail, uniqueness: true, format: { with: Authlogic::Regex::EMAIL_NONASCII } # validates :password, presence: true, if: ->(u){ u.new_record? } validates :email, presence: true, uniqueness: { case_sensitive: false } validates :login, :first_name, presence: true def self.current=(entity) Rails.logger.info("* #{entity.class.name}: #{entity.login} id: #{entity.id}") if entity Thread.current[:"current_#{name.underscore}"] = entity end def self.current Thread.current[:"current_#{name.underscore}"] ||= "#{self}::Anonymous".constantize.new end def name "#{first_name} #{last_name}" end def name=(string) self.first_name, self.last_name = string.split(" ") end def status_new? pending? end def lock? !active? end alias_method :archive?, :lock? def archive! archived! end def unarchive! active! end alias_method :activate!, :unarchive! end end end
Version data entries
5 entries across 5 versions & 1 rubygems