Class: BetterSeeder::Exporters::Json

Inherits:
Base
  • Object
show all
Defined in:
lib/better_seeder/exporters/json.rb

Instance Attribute Summary

Attributes inherited from Base

#data, #output_path, #table_name

Instance Method Summary collapse

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

#exportObject

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

#extensionObject



15
16
17
# File 'lib/better_seeder/exporters/json.rb', line 15

def extension
  '.json'
end