Class: DumpedRailers::FixtureBuilder::Model

Inherits:
Object
  • Object
show all
Defined in:
lib/dumped_railers/fixture_builder/model.rb

Instance Method Summary collapse

Constructor Details

#initialize(model, preprocessors:) ⇒ Model

Returns a new instance of Model.



8
9
10
11
12
13
# File 'lib/dumped_railers/fixture_builder/model.rb', line 8

def initialize(model, preprocessors:)
  @model = model
  @fixture_records = model.order(:id).map { |record|
    Record.new(record, model, preprocessors: preprocessors)
  }
end

Instance Method Details

#build!Object



15
16
17
18
19
20
# File 'lib/dumped_railers/fixture_builder/model.rb', line 15

def build!
  fixture_body = @fixture_records.map(&:build!).to_h
  fixture = fixture_body.reverse_merge build_fixture_header_for(@model)
  
  [@model.table_name, fixture]
end