adjustable_schema 0.11.0 → 0.11.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5514bed45ea4246eb3af8f2331cbc0d911aa3582fadd0cf6fb3ec6fbb61f9c00
4
- data.tar.gz: e042af98603878baa75b1f2a922157dd764572f568d3a836b73c509e654dd2d3
3
+ metadata.gz: 2857a886692a24ac2506137f2962966e6bbcde416b8b3fed091e0fc219a8b81a
4
+ data.tar.gz: f46a4a33c5f3cb201bfdcebbd54c6e1854c3b1f21eb44ba1a05befea056c8d47
5
5
  SHA512:
6
- metadata.gz: e5d3a6f67b13c183c2728582df56f03337362b087e8486130758cdaacd87c72215dd74099a98be202d185b7a84c044d892469122f6850fadc81de6c3e98036a4
7
- data.tar.gz: 2e7113dd0df58bb104086316d4c883e3fe96c2e1eb3b96bb201567937a799edd16502c303fd05a091a83d8afb6e3481a4157a7d2402fc596a80abb01fe493866
6
+ metadata.gz: 44e84ec51c7d255d309499fad94e346062d7cb07164d202148f71c9e54ab8f00fd18d728053e504405fbc01860b1213a35d128dc81f1be2fa0ec6d357340b512
7
+ data.tar.gz: deb4ad146c70fd8ccd8eafbe943d49f68e8ce4526afc7e8ec44adad3e0cb937c3c1e82f394775b36405bb9312f4324f4760dc417e8c34a767ffaa11e5a166ea1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [0.11.1] — 2025-05-19
2
+
3
+ ### Fixed
4
+
5
+ - Associations setup for inherited models got broken in v0.11.0.
6
+
7
+
1
8
  ## [0.11.0] — 2025-05-09
2
9
 
3
10
  ### Changed
data/README.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Adjustable Schema for Rails
2
2
 
3
+ ![GitHub Actions Workflow Status](
4
+ https://img.shields.io/github/actions/workflow/status/Alexander-Senko/adjustable_schema/ci.yml
5
+ )
6
+ ![Code Climate maintainability](
7
+ https://img.shields.io/codeclimate/maintainability-percentage/Alexander-Senko/adjustable_schema
8
+ )
9
+ ![Code Climate coverage](
10
+ https://img.shields.io/codeclimate/coverage/Alexander-Senko/adjustable_schema
11
+ )
12
+
3
13
  Define your model associations in the database without changing the schema or models.
4
14
 
5
15
  This Rails Engine was renamed and refactored from [Rails Dynamic Associations](https://github.com/Alexander-Senko/rails_dynamic_associations).
@@ -1,12 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'memery'
4
+
3
5
  module AdjustableSchema
4
6
  module ActiveRecord # :nodoc:
5
7
  concern :Associations do
6
8
  class_methods do
7
- private
9
+ include Memery
10
+
11
+ protected
12
+
13
+ memoize def adjust_associations
14
+ adjust_parent_associations
8
15
 
9
- def adjust_associations
10
16
  relationships
11
17
  .flat_map do |direction, relationships|
12
18
  relationships
@@ -19,6 +25,17 @@ module AdjustableSchema
19
25
  &.tap do # finally, if any relationships have been set up
20
26
  include Relationships::InstanceMethods
21
27
  end
28
+ &.size # optimization
29
+ end
30
+
31
+ private
32
+
33
+ def adjust_parent_associations
34
+ return unless superclass < Associations
35
+
36
+ superclass.adjust_associations
37
+
38
+ _reflections.reverse_merge! superclass._reflections # update
22
39
  end
23
40
 
24
41
  def setup_association direction, target = self, role = nil
@@ -11,9 +11,12 @@ module AdjustableSchema
11
11
  include Memery
12
12
 
13
13
  memoize def relationships
14
- Config.association_directions.index_with do
15
- Relationship.abstract.send Config.shortcuts.opposite[it], self
16
- end
14
+ Config.association_directions
15
+ .with_opposite
16
+ .transform_values do
17
+ Relationship.abstract
18
+ .where "#{it}_type": name
19
+ end
17
20
  end
18
21
 
19
22
  def roles(&) = Role.of self, &
@@ -19,6 +19,12 @@ module AdjustableSchema
19
19
 
20
20
  include Memery
21
21
 
22
+ class << self
23
+ include Memery
24
+
25
+ memoize :new # unique
26
+ end
27
+
22
28
  def initialize(...)
23
29
  super
24
30
 
@@ -33,7 +39,7 @@ module AdjustableSchema
33
39
  has_many name, **options do
34
40
  include Scopes
35
41
  include Scopes::Recursive if association.recursive?
36
- end
42
+ end or return
37
43
 
38
44
  define_scopes
39
45
  define_methods
@@ -34,6 +34,10 @@ module AdjustableSchema
34
34
  grep_v(to).sole
35
35
  end
36
36
 
37
+ def with_opposite
38
+ index_with { opposite to: it }
39
+ end
40
+
37
41
  private
38
42
 
39
43
  def config section = nil
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AdjustableSchema
4
- VERSION = '0.11.0'
4
+ VERSION = '0.11.1'
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adjustable_schema
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Senko
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-05-08 00:00:00.000000000 Z
10
+ date: 2025-05-19 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rails
@@ -107,7 +107,7 @@ licenses:
107
107
  metadata:
108
108
  homepage_uri: https://github.com/Alexander-Senko/adjustable_schema
109
109
  source_code_uri: https://github.com/Alexander-Senko/adjustable_schema
110
- changelog_uri: https://github.com/Alexander-Senko/adjustable_schema/blob/v0.11.0/CHANGELOG.md
110
+ changelog_uri: https://github.com/Alexander-Senko/adjustable_schema/blob/v0.11.1/CHANGELOG.md
111
111
  rdoc_options: []
112
112
  require_paths:
113
113
  - lib