better_record 0.22.4 → 0.22.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d426d50cc2eb9e82f0aaaddbe50f9ca65381cca3af47576860b919f55e7ab2cf
4
- data.tar.gz: 26e92d8f35ff71f9c297f274f2e96df77064d5f4995fb73c54188b964f343532
3
+ metadata.gz: f4d23ae910e5777201c932f569405099050acae9761fcbc320f5da78d8c6b08a
4
+ data.tar.gz: 0a5901d81b9468f06bf7fa58bba90449cfc84126d3333a14d7ce007e7305a7a4
5
5
  SHA512:
6
- metadata.gz: 260ce5d391640da67b9046744fdae9441b2c7be2972e8c249a3957b625af1a4f508ca31053bf063035fd1ef8c1eef58da89e79de50ae225d41027a4eee12906c
7
- data.tar.gz: 68e6e7120f64441c6281747a051cbf908337595085ca8a8cdd24769585856d94e96def576a8845b7f93fa0e197d6fb0a0427421731f05de1cda8eac80ed55846
6
+ metadata.gz: ad293180c34f9fa78a089b59452230550599db7f73cac893d080bce986b44d9cabb9bfa3b6ed62d461477965672a31808c9c055f98e5b640b81cf32103d7a64c
7
+ data.tar.gz: 42dd7e2e3ece6d1b6f7ba797e30bceed78ebb36f9677c0b9e1ede660b4738875558da1df4e747614598320cb970e17b5116d6804016cdfa2463e02a6baa5489e
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/concern'
4
+ require 'active_record/associations'
5
+ require 'active_record/associations/association'
6
+
7
+ module BetterRecord
8
+ module AssociationsExtensions
9
+ module AssociationExtensions
10
+ extend ActiveSupport::Concern
11
+
12
+ included do
13
+ def creation_attributes
14
+ attributes = {}
15
+
16
+ if (reflection.has_one? || reflection.collection?) && !options[:through]
17
+ attributes[reflection.foreign_key] = owner[reflection.active_record_primary_key]
18
+
19
+ if reflection.type
20
+ attributes[reflection.type] = get_type_value
21
+ end
22
+ end
23
+
24
+ attributes
25
+ end
26
+
27
+ def get_type_value
28
+ BetterRecord::PolymorphicOverride.polymorphic_value(owner.class, reflection.options)
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+
35
+ ActiveRecord::Associations::Association.send(:include, BetterRecord::AssociationsExtensions::AssociationExtensions)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BetterRecord
4
- VERSION = '0.22.4'
4
+ VERSION = '0.22.5'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: better_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.22.4
4
+ version: 0.22.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sampson Crowley
@@ -282,6 +282,7 @@ files:
282
282
  - db/postgres-audit-v3-trigger.psql
283
283
  - lib/better_record.rb
284
284
  - lib/better_record/batches.rb
285
+ - lib/better_record/concerns/active_record_extensions/associations_extensions/association_extension.rb
285
286
  - lib/better_record/concerns/active_record_extensions/associations_extensions/association_scope_extensions.rb
286
287
  - lib/better_record/concerns/active_record_extensions/associations_extensions/belongs_to_polymorphic_extensions.rb
287
288
  - lib/better_record/concerns/active_record_extensions/associations_extensions/builder_extensions/association_extensions.rb