module Sequel::SchemaCaching

Public Instance Methods

dump_schema_cache(file) click to toggle source

Dump the cached schema to the filename given in Marshal format.

# File lib/sequel/extensions/schema_caching.rb, line 52
def dump_schema_cache(file)
  sch = {}
  @schemas.sort.each do |k,v|
    sch[k] = v.map do |c, h|
      h = Hash[h]
      h.delete(:callable_default)
      [c, h]
    end
  end
  File.open(file, 'wb'){|f| f.write(Marshal.dump(sch))}
  nil
end
dump_schema_cache?(file) click to toggle source

Dump the cached schema to the filename given unless the file already exists.

# File lib/sequel/extensions/schema_caching.rb, line 67
def dump_schema_cache?(file)
  dump_schema_cache(file) unless File.exist?(file)
end
load_schema_cache(file) click to toggle source

Replace the schema cache with the data from the given file, which should be in Marshal format.

# File lib/sequel/extensions/schema_caching.rb, line 73
def load_schema_cache(file)
  @schemas = Marshal.load(File.read(file))
  @schemas.each_value{|v| schema_post_process(v)}
  nil
end
load_schema_cache?(file) click to toggle source

Replace the schema cache with the data from the given file if the file exists.

# File lib/sequel/extensions/schema_caching.rb, line 81
def load_schema_cache?(file)
  load_schema_cache(file) if File.exist?(file)
end