Class: SchemaDoctor::SchemaFile
- Inherits:
-
Object
- Object
- SchemaDoctor::SchemaFile
- Defined in:
- lib/schema_doctor/schema_file.rb
Instance Method Summary collapse
Instance Method Details
#delete ⇒ Object
26 27 28 |
# File 'lib/schema_doctor/schema_file.rb', line 26 def delete FileUtils.rm_rf(schema_dir) end |
#dump(specs) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/schema_doctor/schema_file.rb', line 16 def dump(specs) # Output specification files for each model FileUtils.mkdir_p(schema_dir) Utils.deep_stringify(specs).each do |name, spec| File.open("#{schema_dir}/#{name}.yml", "w") do |f| YAML.dump({name => spec}, f) end end end |
#load ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/schema_doctor/schema_file.rb', line 7 def load return unless Dir.exist?(schema_dir) # Load schema specification files and merge them into a single hash Dir.glob("#{schema_dir}/*").inject({}) do |hash, file| hash.merge(YAML.load_file(file, symbolize_names: true)) end end |