Kouhei Sutou
null+****@clear*****
Tue Aug 30 16:18:03 JST 2016
Kouhei Sutou 2016-08-30 16:18:03 +0900 (Tue, 30 Aug 2016) New Revision: 69c344d0c5e1db5198147583e673189b67dfcb05 https://github.com/groonga/groonga/commit/69c344d0c5e1db5198147583e673189b67dfcb05 Message: mrb: support finding Context::RC by code Modified files: lib/mrb/scripts/context/rc.rb Modified: lib/mrb/scripts/context/rc.rb (+12 -4) =================================================================== --- lib/mrb/scripts/context/rc.rb 2016-08-30 16:04:09 +0900 (f2fecbe) +++ lib/mrb/scripts/context/rc.rb 2016-08-30 16:18:03 +0900 (42347e9) @@ -1,15 +1,21 @@ module Groonga class Context class RC + @@codes = {} @@names = {} class << self - def find(name) - @@names[name] || UNKNOWN_ERROR + def find(name_or_code) + if name_or_code.is_a?(String) + @@names[name_or_code] || UNKNOWN_ERROR + else + @@codes[name_or_code] || UNKNOWN_ERROR + end end def register(name, code, error_class) - rc = new(name, code) + rc = new(name, code, error_class) + @@codes[code] = rc @@names[name] = rc error_class.rc = rc if error_class rc @@ -17,9 +23,11 @@ module Groonga end attr_reader :name - def initialize(name, code) + attr_reader :error_class + def initialize(name, code, error_class) @name = name @code = code + @error_class = error_class end def to_i -------------- next part -------------- HTML����������������������������... Descargar