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
53 def dump_schema_cache(file)
54   sch = dumpable_schema_cache
55   File.open(file, 'wb'){|f| f.write(Marshal.dump(sch))}
56   nil
57 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
61 def dump_schema_cache?(file)
62   dump_schema_cache(file) unless File.exist?(file)
63 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
67 def load_schema_cache(file)
68   @schemas = load_schema_cache_file(file)
69   @schemas.each_value{|v| schema_post_process(v)}
70   nil
71 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
75 def load_schema_cache?(file)
76   load_schema_cache(file) if File.exist?(file)
77 end

Private Instance Methods

dumpable_schema_cache() click to toggle source

A dumpable version of the schema cache.

   # File lib/sequel/extensions/schema_caching.rb
87 def dumpable_schema_cache
88   sch = {}
89 
90   @schemas.sort.each do |k,v|
91     sch[k] = v.map do |c, h|
92       h = Hash[h]
93       h.delete(:callable_default)
94       [c, h]
95     end
96   end
97 
98   sch
99 end
load_schema_cache_file(file) click to toggle source

Return the deserialized schema cache file.

   # File lib/sequel/extensions/schema_caching.rb
82 def load_schema_cache_file(file)
83   Marshal.load(File.read(file))
84 end