class ActiveGroonga::Schema
Public Class Methods
define(options={}, &block)
click to toggle source
# File lib/active_groonga/schema.rb, line 21 def define(options={}, &block) new(options).define(&block) end
dump(options={})
click to toggle source
# File lib/active_groonga/schema.rb, line 25 def dump(options={}) options ||= {} if options.is_a?(Hash) options = options.dup output = options.delete(:output) else output, options = options, {} end new(options).dump(output) end
new(options={})
click to toggle source
# File lib/active_groonga/schema.rb, line 37 def initialize(options={}) @options = (options || {}).dup @version = @options.delete(:version) context = @options.delete(:context) || Base.context @schema = Groonga::Schema.new(:context => context) end
Public Instance Methods
define() { |schema| ... }
click to toggle source
# File lib/active_groonga/schema.rb, line 44 def define(&block) yield(@schema) @schema.define update_version if @version end
dump(output=nil)
click to toggle source
# File lib/active_groonga/schema.rb, line 50 def dump(output=nil) dumped_schema = @schema.dump return nil if dumped_schema.nil? return_string = false if output.nil? output = StringIO.new return_string = true end version = @version || management_table.current_version output << "ActiveGroonga::Schema.define(:version => #{version}) do |schema|\n" output << " schema.instance_eval do\n" dumped_schema.each_line do |line| if /^\s*$/ =~ line output << line else output << " #{line}" end end output << " end\n" output << "end\n" if return_string output.string else output end end
Private Instance Methods
management_table()
click to toggle source
# File lib/active_groonga/schema.rb, line 79 def management_table @management_table ||= SchemaManagementTable.new end
update_version()
click to toggle source
# File lib/active_groonga/schema.rb, line 83 def update_version management_table.update_version(@version) end