lib/rubix/models/user.rb in rubix-0.5.1 vs lib/rubix/models/user.rb in rubix-0.5.2
- old
+ new
@@ -3,16 +3,15 @@
module Rubix
class User < Model
# Numeric codes for the various user types.
- TYPE_CODES = {
+ zabbix_define :TYPE, {
:normal => 1,
:admin => 2,
:super_admin => 3
- }.freeze
- TYPE_NAMES = TYPE_CODES.invert.freeze
+ }
#
# == Properties & Finding ==
#
@@ -39,12 +38,17 @@
self.user_groups = properties[:user_groups]
self.media = properties[:media]
end
+ def resource_name
+ "#{self.class.resource_name} #{self.username || self.id}"
+ end
+
#
# == Validations ==
#
+
def validate
super()
raise ValidationError.new("A new user must have a password") if new_record? && (password.nil? || password.empty?)
true
end