Kouhei Sutou
null+****@clear*****
Wed Oct 7 18:06:57 JST 2015
Kouhei Sutou 2015-10-07 18:06:57 +0900 (Wed, 07 Oct 2015) New Revision: b8fb765b5df2436e1006537b13454c1ac1beb628 https://github.com/groonga/groonga/commit/b8fb765b5df2436e1006537b13454c1ac1beb628 Message: mrb: add column value read support to Record Modified files: lib/mrb/scripts/record.rb Modified: lib/mrb/scripts/record.rb (+26 -0) =================================================================== --- lib/mrb/scripts/record.rb 2015-10-07 18:05:50 +0900 (ac49275) +++ lib/mrb/scripts/record.rb 2015-10-07 18:06:57 +0900 (cd7d1a4) @@ -8,5 +8,31 @@ module Groonga "@id=#{@id.inspect}, @table=#{@table.inspect}>" end end + + def [](name) + column = find_column(name) + if column.nil? + raise InvalidArgument, "unknown column: <#{absolute_column_name(name)}>" + end + column[@id] + end + + def method_missing(name, *args, &block) + return super unless args.empty? + + column = find_column(name) + return super if column.nil? + + column[@id] + end + + private + def absolute_column_name(name) + "#{@table.name}.#{name}" + end + + def find_column(name) + Context.instance[absolute_column_name(name)] + end end end -------------- next part -------------- HTML����������������������������...Download