Module: Sequel::SchemaCaching
- Defined in:
- lib/sequel/extensions/schema_caching.rb
Instance Method Summary collapse
-
#dump_schema_cache(file) ⇒ Object
Dump the cached schema to the filename given in Marshal format.
-
#dump_schema_cache?(file) ⇒ Boolean
Dump the cached schema to the filename given unless the file already exists.
-
#load_schema_cache(file) ⇒ Object
Replace the schema cache with the data from the given file, which should be in Marshal format.
-
#load_schema_cache?(file) ⇒ Boolean
Replace the schema cache with the data from the given file if the file exists.
Instance Method Details
#dump_schema_cache(file) ⇒ Object
Dump the cached schema to the filename given in Marshal format.
53 54 55 56 |
# File 'lib/sequel/extensions/schema_caching.rb', line 53 def dump_schema_cache(file) File.open(file, 'wb'){|f| f.write(Marshal.dump(@schemas))} nil end |
#dump_schema_cache?(file) ⇒ Boolean
Dump the cached schema to the filename given unless the file already exists.
60 61 62 |
# File 'lib/sequel/extensions/schema_caching.rb', line 60 def dump_schema_cache?(file) dump_schema_cache(file) unless File.exist?(file) end |
#load_schema_cache(file) ⇒ Object
Replace the schema cache with the data from the given file, which should be in Marshal format.
66 67 68 69 |
# File 'lib/sequel/extensions/schema_caching.rb', line 66 def load_schema_cache(file) @schemas = Marshal.load(File.read(file)) nil end |
#load_schema_cache?(file) ⇒ Boolean
Replace the schema cache with the data from the given file if the file exists.
73 74 75 |
# File 'lib/sequel/extensions/schema_caching.rb', line 73 def load_schema_cache?(file) load_schema_cache(file) if File.exist?(file) end |