Class: DbSeeder::Exporter
- Inherits:
-
Object
- Object
- DbSeeder::Exporter
- Defined in:
- lib/db_seeder/exporter.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Instance Method Summary collapse
- #export ⇒ Object
-
#initialize(model, config) ⇒ Exporter
constructor
A new instance of Exporter.
Constructor Details
#initialize(model, config) ⇒ Exporter
Returns a new instance of Exporter.
7 8 9 10 |
# File 'lib/db_seeder/exporter.rb', line 7 def initialize(model, config) @model = model @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
5 6 7 |
# File 'lib/db_seeder/exporter.rb', line 5 def config @config end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
5 6 7 |
# File 'lib/db_seeder/exporter.rb', line 5 def model @model end |
Instance Method Details
#export ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/db_seeder/exporter.rb', line 12 def export records = [] model.find_in_batches(batch_size: config.batch_size) do |batch| records.concat(batch.map(&method(:serialize_record))) end records end |