Module: DatabaseRewinder::InsertRecorder

Defined in:
lib/database_rewinder/active_record_monkey.rb

Defined Under Namespace

Modules: ExecQuery, Execute

Class Method Summary collapse

Class Method Details

.prepended(mod) ⇒ Object

This method actually no longer has to be a ‘prepended` hook because InsertRecorder is a module without a direct method now, but still doing this just for compatibility



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/database_rewinder/active_record_monkey.rb', line 43

def self.prepended(mod)
  if meth = mod.instance_method(:execute)
    if meth.parameters.any? {|type, _name| [:key, :keyreq, :keyrest].include? type }
      mod.send :prepend, Execute::WithKwargs
    else
      mod.send :prepend, Execute::NoKwargs
    end
  end
  if meth = mod.instance_method(:exec_query)
    if meth.parameters.any? {|type, _name| [:key, :keyreq, :keyrest].include? type }
      mod.send :prepend, ExecQuery::WithKwargs
    else
      mod.send :prepend, ExecQuery::NoKwargs
    end
  end
end