From c8d3ffb1ee7474215f47e651dd08d13b19482add Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 5 Sep 2014 08:42:18 +1000 Subject: [PATCH] prep for renaming trust level levels --- lib/trust_level.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/trust_level.rb b/lib/trust_level.rb index 31de49fe3d0..dc9aab0861d 100644 --- a/lib/trust_level.rb +++ b/lib/trust_level.rb @@ -1,9 +1,18 @@ require_dependency 'enum' +class InvalidTrustLevel < StandardError; end class TrustLevel attr_reader :id, :name class << self + + def[](val) + if val < 0 || val > 4 + raise InvalidTrustLevel + end + val + end + def levels @levels ||= Enum.new( :newuser, :basic, :regular, :leader, :elder, start: 0