iknow_view_models 3.11.0 → 3.12.0
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:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 07b80f46184b9f84a29e63b4f26c65b9cf7e7b7fa0a6390365e66c92cbac0325
         | 
| 4 | 
            +
              data.tar.gz: 240963485ad8192d341ad3ce40a5d360052a69055036bf3ca64fb76d2f176c36
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 0ddaba32ebd18303eba6f2e91db5ca44368c538bba771c6572afa4a3b4d7e17efd69ef6bfb274218b2f1fcf73812a8bb62704aa60065c3e45900428eff91e231
         | 
| 7 | 
            +
              data.tar.gz: 7b482657ab857da0848f7880caf8a67a08ecbf132b3495d2117ea89642270525db95bf92fe26160ff0bc9450d3b514e94ca2ef77252f47a0ae6f04934a49efd0
         | 
| @@ -522,6 +522,10 @@ class ViewModel::ActiveRecord | |
| 522 522 |  | 
| 523 523 | 
             
                delegate :new?, :child_update?, :auto_child_update?, to: :metadata
         | 
| 524 524 |  | 
| 525 | 
            +
                def reference_only?
         | 
| 526 | 
            +
                  attributes.empty? && associations.empty? && referenced_associations.empty?
         | 
| 527 | 
            +
                end
         | 
| 528 | 
            +
             | 
| 525 529 | 
             
                def self.parse_hashes(root_subtree_hashes, referenced_subtree_hashes = {})
         | 
| 526 530 | 
             
                  valid_reference_keys = referenced_subtree_hashes.keys.to_set
         | 
| 527 531 |  | 
| @@ -44,6 +44,10 @@ class ViewModel::ActiveRecord | |
| 44 44 | 
             
                  @built
         | 
| 45 45 | 
             
                end
         | 
| 46 46 |  | 
| 47 | 
            +
                def reference_only?
         | 
| 48 | 
            +
                  update_data.reference_only? && reparent_to.nil? && reposition_to.nil?
         | 
| 49 | 
            +
                end
         | 
| 50 | 
            +
             | 
| 47 51 | 
             
                # Evaluate a built update tree, applying and saving changes to the models.
         | 
| 48 52 | 
             
                def run!(deserialize_context:)
         | 
| 49 53 | 
             
                  raise ViewModel::DeserializationError::Internal.new('Internal error: UpdateOperation run before build') unless built?
         | 
| @@ -123,9 +127,14 @@ class ViewModel::ActiveRecord | |
| 123 127 | 
             
                        end
         | 
| 124 128 | 
             
                      end
         | 
| 125 129 |  | 
| 126 | 
            -
                      #  | 
| 127 | 
            -
                       | 
| 128 | 
            -
                       | 
| 130 | 
            +
                      # If a request makes no assertions about the model, we don't demand
         | 
| 131 | 
            +
                      # that the current state of the model is valid. This permits making
         | 
| 132 | 
            +
                      # edits to other models that refer to this model when this model is
         | 
| 133 | 
            +
                      # invalid.
         | 
| 134 | 
            +
                      unless reference_only? && !viewmodel.new_model?
         | 
| 135 | 
            +
                        deserialize_context.run_callback(ViewModel::Callbacks::Hook::BeforeValidate, viewmodel)
         | 
| 136 | 
            +
                        viewmodel.validate!
         | 
| 137 | 
            +
                      end
         | 
| 129 138 |  | 
| 130 139 | 
             
                      # Save if the model has been altered. Covers not only models with
         | 
| 131 140 | 
             
                      # view changes but also lock version assertions.
         | 
    
        data/lib/view_model/migration.rb
    CHANGED
    
    | @@ -5,8 +5,18 @@ class ViewModel::Migration | |
| 5 5 | 
             
              require 'view_model/migration/one_way_error'
         | 
| 6 6 | 
             
              require 'view_model/migration/unspecified_version_error'
         | 
| 7 7 |  | 
| 8 | 
            +
              REFERENCE_ONLY_KEYS = [
         | 
| 9 | 
            +
                ViewModel::TYPE_ATTRIBUTE,
         | 
| 10 | 
            +
                ViewModel::ID_ATTRIBUTE,
         | 
| 11 | 
            +
                ViewModel::VERSION_ATTRIBUTE,
         | 
| 12 | 
            +
              ].freeze
         | 
| 13 | 
            +
             | 
| 8 14 | 
             
              def up(view, _references)
         | 
| 9 | 
            -
                 | 
| 15 | 
            +
                # Only a reference-only view may be (trivially) migrated up without an
         | 
| 16 | 
            +
                # explicit migration.
         | 
| 17 | 
            +
                if (view.keys - REFERENCE_ONLY_KEYS).present?
         | 
| 18 | 
            +
                  raise ViewModel::Migration::OneWayError.new(view[ViewModel::TYPE_ATTRIBUTE], :up)
         | 
| 19 | 
            +
                end
         | 
| 10 20 | 
             
              end
         | 
| 11 21 |  | 
| 12 22 | 
             
              def down(view, _references)
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: iknow_view_models
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 3. | 
| 4 | 
            +
              version: 3.12.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - iKnow Team
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2024- | 
| 11 | 
            +
            date: 2024-10-02 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: actionpack
         |