hoardable 0.19.0 → 0.19.2
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 +8 -0
- data/Gemfile +5 -0
- data/lib/hoardable/database_client.rb +1 -3
- data/lib/hoardable/engine.rb +17 -13
- data/lib/hoardable/model.rb +13 -10
- data/lib/hoardable/scopes.rb +2 -2
- data/lib/hoardable/version.rb +1 -1
- metadata +3 -6
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: affe4a55357ac085a712046c50d2742c7f1887947dee2a7e4d221cf5c7fd7086
         | 
| 4 | 
            +
              data.tar.gz: 7b2112637801d32e5f18a93d3aa54077e631d25fd9ef6a85639770910d87024b
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: dfdf425df919edd8abce1942108881469c3c29b4e3e0ac9641ab56c221a6c0496f73ae7b6c657aa3edf33ae31b265e15d245e1e4d6e41fedbcbc7983af0657f9
         | 
| 7 | 
            +
              data.tar.gz: 04b2495a301dd95bdd8d7f4af56ea6cf6dac682d7da59e59dee6d40ed031451410344a34f9580551047985009fc17e5ce1ac0e6d83c0a6f531ec071e932788d7
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    | @@ -1,3 +1,11 @@ | |
| 1 | 
            +
            ## 0.19.2
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            - Consult `inheritance_column` when constructing default scope
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            ## 0.19.1
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            - Thread-safety support added for `with_hoardable_config`.
         | 
| 8 | 
            +
             | 
| 1 9 | 
             
            ## 0.19.0
         | 
| 2 10 |  | 
| 3 11 | 
             
            - Ensure that stateful Hoardable class methods `with`, `travel_to` and `at` are thread-safe.
         | 
    
        data/Gemfile
    CHANGED
    
    
| @@ -28,9 +28,7 @@ module Hoardable | |
| 28 28 | 
             
                end
         | 
| 29 29 |  | 
| 30 30 | 
             
                def find_or_initialize_hoardable_event_uuid
         | 
| 31 | 
            -
                  Thread.current[:hoardable_event_uuid] ||=  | 
| 32 | 
            -
                    ActiveRecord::Base.connection.query("SELECT gen_random_uuid();")[0][0]
         | 
| 33 | 
            -
                  )
         | 
| 31 | 
            +
                  Thread.current[:hoardable_event_uuid] ||= SecureRandom.uuid
         | 
| 34 32 | 
             
                end
         | 
| 35 33 |  | 
| 36 34 | 
             
                def initialize_version_attributes(operation)
         | 
    
        data/lib/hoardable/engine.rb
    CHANGED
    
    | @@ -6,7 +6,7 @@ module Hoardable | |
| 6 6 |  | 
| 7 7 | 
             
              # Symbols for use with setting contextual data, when creating versions. See
         | 
| 8 8 | 
             
              # {file:README.md#tracking-contextual-data README} for more.
         | 
| 9 | 
            -
              DATA_KEYS = %i[meta whodunit | 
| 9 | 
            +
              DATA_KEYS = %i[meta whodunit].freeze
         | 
| 10 10 |  | 
| 11 11 | 
             
              # Symbols for use with setting {Hoardable} configuration. See {file:README.md#configuration
         | 
| 12 12 | 
             
              # README} for more.
         | 
| @@ -44,19 +44,13 @@ module Hoardable | |
| 44 44 |  | 
| 45 45 | 
             
              class << self
         | 
| 46 46 | 
             
                CONFIG_KEYS.each do |key|
         | 
| 47 | 
            -
                  define_method(key)  | 
| 48 | 
            -
                    local_config = Thread.current[:hoardable_config] || @config
         | 
| 49 | 
            -
                    local_config[key]
         | 
| 50 | 
            -
                  end
         | 
| 47 | 
            +
                  define_method(key) { hoardable_config[key] }
         | 
| 51 48 |  | 
| 52 49 | 
             
                  define_method("#{key}=") { |value| @config[key] = value }
         | 
| 53 50 | 
             
                end
         | 
| 54 51 |  | 
| 55 52 | 
             
                DATA_KEYS.each do |key|
         | 
| 56 | 
            -
                  define_method(key)  | 
| 57 | 
            -
                    local_context = Thread.current[:hoardable_context] || @context
         | 
| 58 | 
            -
                    local_context[key]
         | 
| 59 | 
            -
                  end
         | 
| 53 | 
            +
                  define_method(key) { hoardable_context[key] }
         | 
| 60 54 |  | 
| 61 55 | 
             
                  define_method("#{key}=") { |value| @context[key] = value }
         | 
| 62 56 | 
             
                end
         | 
| @@ -67,12 +61,22 @@ module Hoardable | |
| 67 61 | 
             
                # @param hash [Hash] config and contextual data to set within a block
         | 
| 68 62 | 
             
                def with(hash)
         | 
| 69 63 | 
             
                  thread = Thread.current
         | 
| 70 | 
            -
                  thread[:hoardable_config] | 
| 71 | 
            -
                  thread[:hoardable_context] | 
| 64 | 
            +
                  current_thread_config = thread[:hoardable_config]
         | 
| 65 | 
            +
                  current_thread_context = thread[:hoardable_context]
         | 
| 66 | 
            +
                  thread[:hoardable_config] = hoardable_config.merge(hash.slice(*CONFIG_KEYS))
         | 
| 67 | 
            +
                  thread[:hoardable_context] = hoardable_context.merge(hash.slice(*DATA_KEYS))
         | 
| 72 68 | 
             
                  yield
         | 
| 73 69 | 
             
                ensure
         | 
| 74 | 
            -
                  thread[:hoardable_config] =  | 
| 75 | 
            -
                  thread[:hoardable_context] =  | 
| 70 | 
            +
                  thread[:hoardable_config] = current_thread_config
         | 
| 71 | 
            +
                  thread[:hoardable_context] = current_thread_context
         | 
| 72 | 
            +
                end
         | 
| 73 | 
            +
             | 
| 74 | 
            +
                private def hoardable_config
         | 
| 75 | 
            +
                  @config.merge(Thread.current[:hoardable_config] ||= {})
         | 
| 76 | 
            +
                end
         | 
| 77 | 
            +
             | 
| 78 | 
            +
                private def hoardable_context
         | 
| 79 | 
            +
                  @context.merge(Thread.current[:hoardable_context] ||= {})
         | 
| 76 80 | 
             
                end
         | 
| 77 81 |  | 
| 78 82 | 
             
                # Allows performing a query for record states at a certain time. Returned {SourceModel}
         | 
    
        data/lib/hoardable/model.rb
    CHANGED
    
    | @@ -9,9 +9,6 @@ module Hoardable | |
| 9 9 | 
             
                extend ActiveSupport::Concern
         | 
| 10 10 |  | 
| 11 11 | 
             
                class_methods do
         | 
| 12 | 
            -
                  # @!visibility private
         | 
| 13 | 
            -
                  attr_reader :_hoardable_config
         | 
| 14 | 
            -
             | 
| 15 12 | 
             
                  # If called with a hash, this will set the model-level +Hoardable+ configuration variables. If
         | 
| 16 13 | 
             
                  # called without an argument it will return the computed +Hoardable+ configuration considering
         | 
| 17 14 | 
             
                  # both model-level and global values.
         | 
| @@ -23,10 +20,7 @@ module Hoardable | |
| 23 20 | 
             
                    if hash
         | 
| 24 21 | 
             
                      @_hoardable_config = hash.slice(*CONFIG_KEYS)
         | 
| 25 22 | 
             
                    else
         | 
| 26 | 
            -
                       | 
| 27 | 
            -
                      CONFIG_KEYS.to_h do |key|
         | 
| 28 | 
            -
                        [key, @_hoardable_config.key?(key) ? @_hoardable_config[key] : Hoardable.send(key)]
         | 
| 29 | 
            -
                      end
         | 
| 23 | 
            +
                      CONFIG_KEYS.to_h { |key| [key, _hoardable_config.fetch(key) { Hoardable.send(key) }] }
         | 
| 30 24 | 
             
                    end
         | 
| 31 25 | 
             
                  end
         | 
| 32 26 |  | 
| @@ -36,11 +30,20 @@ module Hoardable | |
| 36 30 | 
             
                  # @param hash [Hash] The +Hoardable+ configuration for the model. Keys must be present in
         | 
| 37 31 | 
             
                  #   {CONFIG_KEYS}
         | 
| 38 32 | 
             
                  def with_hoardable_config(hash)
         | 
| 39 | 
            -
                     | 
| 40 | 
            -
                     | 
| 33 | 
            +
                    thread = Thread.current
         | 
| 34 | 
            +
                    current_thread_config = thread[hoardable_current_config_key]
         | 
| 35 | 
            +
                    thread[hoardable_current_config_key] = _hoardable_config.merge(hash.slice(*CONFIG_KEYS))
         | 
| 41 36 | 
             
                    yield
         | 
| 42 37 | 
             
                  ensure
         | 
| 43 | 
            -
                     | 
| 38 | 
            +
                    thread[hoardable_current_config_key] = current_thread_config
         | 
| 39 | 
            +
                  end
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                  private def _hoardable_config
         | 
| 42 | 
            +
                    (@_hoardable_config ||= {}).merge(Thread.current[hoardable_current_config_key] ||= {})
         | 
| 43 | 
            +
                  end
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                  private def hoardable_current_config_key
         | 
| 46 | 
            +
                    "hoardable_#{name}_config".to_sym
         | 
| 44 47 | 
             
                  end
         | 
| 45 48 | 
             
                end
         | 
| 46 49 |  | 
    
        data/lib/hoardable/scopes.rb
    CHANGED
    
    | @@ -20,9 +20,9 @@ module Hoardable | |
| 20 20 | 
             
                          exclude_versions
         | 
| 21 21 | 
             
                        end
         | 
| 22 22 | 
             
                      )
         | 
| 23 | 
            -
                    next scope unless klass == version_class &&  | 
| 23 | 
            +
                    next scope unless klass == version_class && superclass.inheritance_column.in?(column_names)
         | 
| 24 24 |  | 
| 25 | 
            -
                    scope.where( | 
| 25 | 
            +
                    scope.where(superclass.inheritance_column => superclass.sti_name)
         | 
| 26 26 | 
             
                  end
         | 
| 27 27 |  | 
| 28 28 | 
             
                  # @!scope class
         | 
    
        data/lib/hoardable/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,13 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: hoardable
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.19. | 
| 4 | 
            +
              version: 0.19.2
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - justin talbott
         | 
| 8 | 
            -
            autorequire:
         | 
| 9 8 | 
             
            bindir: exe
         | 
| 10 9 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2025- | 
| 10 | 
            +
            date: 2025-04-08 00:00:00.000000000 Z
         | 
| 12 11 | 
             
            dependencies:
         | 
| 13 12 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 13 | 
             
              name: activerecord
         | 
| @@ -162,7 +161,6 @@ metadata: | |
| 162 161 | 
             
              homepage_uri: https://github.com/waymondo/hoardable
         | 
| 163 162 | 
             
              source_code_uri: https://github.com/waymondo/hoardable
         | 
| 164 163 | 
             
              rubygems_mfa_required: 'true'
         | 
| 165 | 
            -
            post_install_message:
         | 
| 166 164 | 
             
            rdoc_options: []
         | 
| 167 165 | 
             
            require_paths:
         | 
| 168 166 | 
             
            - lib
         | 
| @@ -177,8 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 177 175 | 
             
                - !ruby/object:Gem::Version
         | 
| 178 176 | 
             
                  version: '0'
         | 
| 179 177 | 
             
            requirements: []
         | 
| 180 | 
            -
            rubygems_version: 3. | 
| 181 | 
            -
            signing_key:
         | 
| 178 | 
            +
            rubygems_version: 3.6.2
         | 
| 182 179 | 
             
            specification_version: 4
         | 
| 183 180 | 
             
            summary: An ActiveRecord extension for versioning and soft-deletion of records in
         | 
| 184 181 | 
             
              Postgres
         |