summaryrefslogtreecommitdiff
path: root/storage/mroonga/vendor/groonga/lib/mrb/scripts/command.rb
blob: c4e3e94bc4ece254742a0bafb24f8d54603700f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
module Groonga
  class Command
    @@classes = {}
    class << self
      def register_class(name, klass)
        @@classes[name] = klass
      end

      def find_class(name)
        @@classes[name]
      end
    end

    private
    def context
      @context ||= Context.instance
    end

    def writer
      @writer ||= context.writer
    end

    def run_internal(input)
      begin
        run_body(input)
      rescue GroongaError => groonga_error
        context.set_groonga_error(groonga_error)
        nil
      rescue => error
        context.record_error(:command_error, error)
        nil
      end
    end
  end
end