Module: Immunio::StatementCacheHooks::ClassMethods

Defined in:
lib/immunio/plugins/active_record_relation.rb

Instance Method Summary collapse

Instance Method Details

#create_with_immunio(*args, &block) ⇒ Object

When a statement is cached, store the final relation used to generate the statement in a special immunio instance variable.



259
260
261
262
263
264
265
266
267
268
# File 'lib/immunio/plugins/active_record_relation.rb', line 259

def create_with_immunio(*args, &block)
  # The relation is returned by the block passed into the create method.
  # This is more fragile than most of our method wrappings as we depend on
  # *how* the method works, but there's no way around it.
  relation = block.call ActiveRecord::StatementCache::Params.new

  ret = create_without_immunio(*args) { relation }
  ret.instance_variable_set :@__immunio_relation, relation
  ret
end