Module: DatabaseRecorder::ActiveRecord::BaseExt

Defined in:
lib/database_recorder/active_record/base_ext.rb

Instance Method Summary collapse

Instance Method Details

#create_or_update(&block) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/database_recorder/active_record/base_ext.rb', line 6

def create_or_update(**, &block)
  return super if !new_record? || !Recording.started?

  cached = Config.replay_recordings && Recording.from_cache ? Recording.pull_entity : false
  if cached
    # self.id = cached['id']
    super
  else
    super.tap do |_result|
      Recording.new_entity(model: self.class.to_s, id: id)
    end
  end
end