Module: Torque::PostgreSQL::Relation::Initializer

Includes:
Buckets::Initializer
Defined in:
lib/torque/postgresql/relation.rb

Overview

When a relation is created, force the attributes to be defined, because the type mapper may add new methods to the model. This happens for the given model Klass and its inheritances

Instance Method Summary collapse

Methods included from Buckets::Initializer

#records

Instance Method Details

#initialize(klass) ⇒ Object



122
123
124
125
126
127
# File 'lib/torque/postgresql/relation.rb', line 122

def initialize(klass, *, **)
  super

  klass.superclass.send(:relation) if klass.define_attribute_methods &&
    klass.superclass != ActiveRecord::Base && !klass.superclass.abstract_class?
end

#upsert_all(attributes, **xargs) ⇒ Object

Allow extra keyword arguments to be sent to InsertAll



130
131
132
133
# File 'lib/torque/postgresql/relation.rb', line 130

def upsert_all(attributes, **xargs)
  xargs = xargs.reverse_merge(on_duplicate: :update)
  ::ActiveRecord::InsertAll.execute(self, attributes, **xargs)
end