Module: Torque::PostgreSQL::Relation::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

Instance Method Details

#initialize(klass) ⇒ Object



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

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



139
140
141
142
# File 'lib/torque/postgresql/relation.rb', line 139

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