Sha256: 63911888484ee7127a913ce85445ec1461e65a284fe6506a3b03e198697905a8
Contents?: true
Size: 1.32 KB
Versions: 6
Compression:
Stored size: 1.32 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) words = string.split(" ") self.first_name = words[0..-2].join(" ") self.last_name = words[-1] 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
6 entries across 6 versions & 1 rubygems