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 +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +10 -0
- data/app/models/concerns/adjustable_schema/active_record/associations.rb +19 -2
- data/app/models/concerns/adjustable_schema/active_record/relationships.rb +6 -3
- data/lib/adjustable_schema/active_record/association.rb +7 -1
- data/lib/adjustable_schema/config.rb +4 -0
- data/lib/adjustable_schema/version.rb +1 -1
- metadata +3 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 2857a886692a24ac2506137f2962966e6bbcde416b8b3fed091e0fc219a8b81a
         | 
| 4 | 
            +
              data.tar.gz: f46a4a33c5f3cb201bfdcebbd54c6e1854c3b1f21eb44ba1a05befea056c8d47
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 44e84ec51c7d255d309499fad94e346062d7cb07164d202148f71c9e54ab8f00fd18d728053e504405fbc01860b1213a35d128dc81f1be2fa0ec6d357340b512
         | 
| 7 | 
            +
              data.tar.gz: deb4ad146c70fd8ccd8eafbe943d49f68e8ce4526afc7e8ec44adad3e0cb937c3c1e82f394775b36405bb9312f4324f4760dc417e8c34a767ffaa11e5a166ea1
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | @@ -1,5 +1,15 @@ | |
| 1 1 | 
             
            # Adjustable Schema for Rails
         | 
| 2 2 |  | 
| 3 | 
            +
            
         | 
| 6 | 
            +
            
         | 
| 9 | 
            +
            
         | 
| 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 | 
            -
            				 | 
| 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 | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 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
         | 
    
        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. | 
| 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- | 
| 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. | 
| 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
         |