immosquare-active-record-change-tracker 0.1.0 → 0.1.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:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 7c2d32963fc17f1c7ef7655b942f8e61beb136d1bd0811dbd6f3427df3c7d8ab
         | 
| 4 | 
            +
              data.tar.gz: b2302a16458ffe0595584fddbbc74e08e00e6271639a69ee04132ffcb3d01531
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 0afaaae031be8e2933b2a6575fa71cfdcd0f84ec5d522c1ad6d82ce0ee0e59e43d5236bb73e20c06416be5e1f839b5678abeea7cebe4471212c23822d91ead67
         | 
| 7 | 
            +
              data.tar.gz: d398dff8fc42d43d88c93736cb3f82639cf3696a940fa0a8e07a4a6109502bdea89b01081ca0b8a176330711d75ce7e31a3457d4a4860c059a8fb9917d8d9562
         | 
| @@ -15,6 +15,15 @@ module ImmosquareActiveRecordChangeTracker | |
| 15 15 | 
             
                  ##============================================================##
         | 
| 16 16 | 
             
                  include(ImmosquareActiveRecordChangeTracker::InstanceMethods)
         | 
| 17 17 |  | 
| 18 | 
            +
                  ##============================================================##
         | 
| 19 | 
            +
                  ## Ajout de l'association has_many :history_records
         | 
| 20 | 
            +
                  ##============================================================##
         | 
| 21 | 
            +
                  has_many(:history_records,
         | 
| 22 | 
            +
                    -> { order(:created_at => :desc) },
         | 
| 23 | 
            +
                    :as         => :recordable,
         | 
| 24 | 
            +
                    :class_name => "ImmosquareActiveRecordChangeTracker::HistoryRecord",
         | 
| 25 | 
            +
                    :dependent  => :destroy)
         | 
| 26 | 
            +
             | 
| 18 27 | 
             
                  ##============================================================##
         | 
| 19 28 | 
             
                  ## Stocker les options dans un attribut de classe
         | 
| 20 29 | 
             
                  ##============================================================##
         | 
| @@ -27,7 +36,7 @@ module ImmosquareActiveRecordChangeTracker | |
| 27 36 | 
             
                  history_options[:modifier_block] = modifier_block if block_given?
         | 
| 28 37 |  | 
| 29 38 | 
             
                  ##============================================================##
         | 
| 30 | 
            -
                  ## Configure le callback after_save
         | 
| 39 | 
            +
                  ## Configure le callback after_save et after_destroy
         | 
| 31 40 | 
             
                  ##============================================================##
         | 
| 32 41 | 
             
                  after_save(:save_change_history)
         | 
| 33 42 | 
             
                  after_destroy(:delete_change_history)
         | 
| @@ -55,7 +64,6 @@ module ImmosquareActiveRecordChangeTracker | |
| 55 64 | 
             
                      previous_changes.except(*excluded_fields.uniq.map(&:to_s))
         | 
| 56 65 | 
             
                    end
         | 
| 57 66 |  | 
| 58 | 
            -
             | 
| 59 67 | 
             
                  ##============================================================##
         | 
| 60 68 | 
             
                  ## Gestion de Globalize
         | 
| 61 69 | 
             
                  ##============================================================##
         | 
| @@ -83,19 +91,18 @@ module ImmosquareActiveRecordChangeTracker | |
| 83 91 | 
             
                    changes_to_save.merge!(globalize_changes)
         | 
| 84 92 | 
             
                  end
         | 
| 85 93 |  | 
| 86 | 
            -
             | 
| 87 94 | 
             
                  ##============================================================##
         | 
| 88 95 | 
             
                  ## Si aucun changement à sauvegarder, on sort
         | 
| 89 96 | 
             
                  ##============================================================##
         | 
| 90 97 | 
             
                  return if changes_to_save.none?
         | 
| 91 98 |  | 
| 92 99 | 
             
                  ##============================================================##
         | 
| 93 | 
            -
                  ##  | 
| 100 | 
            +
                  ## Récupération du modificateur en exécutant le bloc s'il est défini
         | 
| 94 101 | 
             
                  ##============================================================##
         | 
| 95 102 | 
             
                  modifier = history_options[:modifier_block]&.call
         | 
| 96 103 |  | 
| 97 104 | 
             
                  ##============================================================##
         | 
| 98 | 
            -
                  ## Gestion de l' | 
| 105 | 
            +
                  ## Gestion de l'événement (create ou update)
         | 
| 99 106 | 
             
                  ##============================================================##
         | 
| 100 107 | 
             
                  event = previously_new_record? ? "create" : "update"
         | 
| 101 108 |  | 
| @@ -112,7 +119,7 @@ module ImmosquareActiveRecordChangeTracker | |
| 112 119 | 
             
                end
         | 
| 113 120 |  | 
| 114 121 | 
             
                ##============================================================##
         | 
| 115 | 
            -
                ## Stocker l' | 
| 122 | 
            +
                ## Stocker l'événement destroy
         | 
| 116 123 | 
             
                ## Pas besoin de data, rien n'a changé.
         | 
| 117 124 | 
             
                ##============================================================##
         | 
| 118 125 | 
             
                def delete_change_history
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: immosquare-active-record-change-tracker
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.1. | 
| 4 | 
            +
              version: 0.1.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - IMMO SQUARE
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2024-10- | 
| 11 | 
            +
            date: 2024-10-07 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies: []
         | 
| 13 13 | 
             
            description: A gem to track changes on ActiveRecord models
         | 
| 14 14 | 
             
            email:
         |