torque-postgresql 2.0.4 → 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/torque/postgresql.rb +0 -1
- data/lib/torque/postgresql/associations/association.rb +4 -0
- data/lib/torque/postgresql/associations/preloader/association.rb +1 -0
- data/lib/torque/postgresql/attributes/builder.rb +1 -1
- data/lib/torque/postgresql/version.rb +1 -1
- metadata +2 -3
- data/lib/torque/postgresql/autosave_association.rb +0 -45
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe8259f8bb0f4c8c67c32919ec2bc2ca448c5372857670ed5fbd4d932e3160d6
|
4
|
+
data.tar.gz: 3786a17977e0d4ffd81c1521c9e469fd411b6d15b413866941adc911beb8c2dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f35b0eb94b260cc5c5c9d08a47dcba841d9044c9acc52d30b0ad13b1e0a6ecbe2ef10ca940828870fbf5f04b387827b9c56db43523e0585f77f950a72e368b51
|
7
|
+
data.tar.gz: a3b899a4c7a26f9ff9a6a9af7f0d41a6ed193e96a76d96ae17a2423eb0b4bc6ea59138684cd324a28ccfad7374528c1cb72d4ae89a0ad710ce66655d3e355e50
|
data/lib/torque/postgresql.rb
CHANGED
@@ -18,7 +18,6 @@ require 'torque/postgresql/arel'
|
|
18
18
|
require 'torque/postgresql/adapter'
|
19
19
|
require 'torque/postgresql/associations'
|
20
20
|
require 'torque/postgresql/attributes'
|
21
|
-
require 'torque/postgresql/autosave_association'
|
22
21
|
require 'torque/postgresql/auxiliary_statement'
|
23
22
|
require 'torque/postgresql/base'
|
24
23
|
require 'torque/postgresql/inheritance'
|
@@ -9,7 +9,7 @@ module Torque
|
|
9
9
|
module Builder
|
10
10
|
def self.include_on(klass, method_name, builder_klass, **extra, &block)
|
11
11
|
klass.define_singleton_method(method_name) do |*args, **options|
|
12
|
-
return unless
|
12
|
+
return unless table_exists?
|
13
13
|
|
14
14
|
args.each do |attribute|
|
15
15
|
begin
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: torque-postgresql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carlos Silva
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -211,7 +211,6 @@ files:
|
|
211
211
|
- lib/torque/postgresql/attributes/enum_set.rb
|
212
212
|
- lib/torque/postgresql/attributes/lazy.rb
|
213
213
|
- lib/torque/postgresql/attributes/period.rb
|
214
|
-
- lib/torque/postgresql/autosave_association.rb
|
215
214
|
- lib/torque/postgresql/auxiliary_statement.rb
|
216
215
|
- lib/torque/postgresql/auxiliary_statement/settings.rb
|
217
216
|
- lib/torque/postgresql/base.rb
|
@@ -1,45 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Torque
|
4
|
-
module PostgreSQL
|
5
|
-
module AutosaveAssociation
|
6
|
-
module ClassMethods
|
7
|
-
def add_autosave_association_callbacks(reflection)
|
8
|
-
return super unless reflection.macro.eql?(:belongs_to_many)
|
9
|
-
|
10
|
-
save_method = :"autosave_associated_records_for_#{reflection.name}"
|
11
|
-
define_non_cyclic_method(save_method) { save_belongs_to_many_array(reflection) }
|
12
|
-
|
13
|
-
if PostgreSQL::AR610
|
14
|
-
around_save(:around_save_collection_association)
|
15
|
-
else
|
16
|
-
before_save(:before_save_collection_association)
|
17
|
-
after_save(:after_save_collection_association) if ::ActiveRecord::Base
|
18
|
-
.instance_methods.include?(:after_save_collection_association)
|
19
|
-
end
|
20
|
-
|
21
|
-
before_create(save_method)
|
22
|
-
before_update(save_method)
|
23
|
-
|
24
|
-
define_autosave_validation_callbacks(reflection)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def save_belongs_to_many_array(reflection)
|
29
|
-
save_collection_association(reflection)
|
30
|
-
|
31
|
-
association = association_instance_get(reflection.name)
|
32
|
-
return unless association
|
33
|
-
|
34
|
-
klass_attr = reflection.active_record_primary_key
|
35
|
-
source_attr = reflection.foreign_key
|
36
|
-
|
37
|
-
records = association.target.each_with_object(klass_attr)
|
38
|
-
write_attribute(source_attr, records.map(&:read_attribute).compact)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
::ActiveRecord::Base.singleton_class.prepend(AutosaveAssociation::ClassMethods)
|
43
|
-
::ActiveRecord::Base.include(AutosaveAssociation)
|
44
|
-
end
|
45
|
-
end
|