Class: BetterSeeder::Exporters::Json
- Defined in:
- lib/better_seeder/exporters/json.rb
Instance Attribute Summary
Attributes inherited from Base
#data, #output_path, #table_name
Instance Method Summary collapse
-
#export ⇒ Object
Esporta i dati in formato JSON e li salva in un file nella cartella “db/seed/preload”.
- #extension ⇒ Object
Methods inherited from Base
#ensure_output_directory, #full_output_path, #initialize, #output_directory
Constructor Details
This class inherits a constructor from BetterSeeder::Exporters::Base
Instance Method Details
#export ⇒ Object
Esporta i dati in formato JSON e li salva in un file nella cartella “db/seed/preload”. Se la cartella non esiste, viene creata automaticamente.
8 9 10 11 12 13 |
# File 'lib/better_seeder/exporters/json.rb', line 8 def export # Imposta la directory di output full_path = File.join(full_output_path) File.write(full_path, JSON.pretty_generate(data)) end |
#extension ⇒ Object
15 16 17 |
# File 'lib/better_seeder/exporters/json.rb', line 15 def extension '.json' end |