Class: Groonga::SchemaDumper

Inherits:
Object
  • Object
show all
Defined in:
lib/groonga/dumper.rb

Overview

スキーマの内容をRubyスクリプトまたはgrn式形式の文字列と して出力するクラス。

Defined Under Namespace

Classes: BaseSyntax, CommandSyntax, RubySyntax

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ SchemaDumper

Returns a new instance of SchemaDumper.



107
108
109
# File 'lib/groonga/dumper.rb', line 107

def initialize(options={})
  @options = (options || {}).dup
end

Instance Method Details

#dumpObject



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/groonga/dumper.rb', line 111

def dump
  database = @options[:database]
  if database.nil?
    context = @options[:context] || Groonga::Context.default
    database = context.database
  end
  return nil if database.nil?

  output = @options[:output]
  have_output = !output.nil?
  output ||= StringIO.new
  result = syntax(database, output).dump
  if have_output
    result
  else
    output.string
  end
end