activemodel 7.0.4.3 → 7.0.8.6
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 +70 -0
 - data/README.rdoc +2 -2
 - data/lib/active_model/attribute_methods.rb +31 -39
 - data/lib/active_model/attribute_mutation_tracker.rb +10 -2
 - data/lib/active_model/callbacks.rb +1 -1
 - data/lib/active_model/error.rb +1 -1
 - data/lib/active_model/gem_version.rb +2 -2
 - data/lib/active_model/type/binary.rb +6 -2
 - data/lib/active_model/type/helpers/mutable.rb +4 -0
 - data/lib/active_model/type/value.rb +8 -0
 - data/lib/active_model/validations/callbacks.rb +6 -8
 - data/lib/active_model/validations/length.rb +3 -4
 - data/lib/active_model/validations/validates.rb +1 -1
 - data/lib/active_model.rb +1 -0
 - metadata +11 -11
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: e289cdc76a9ec9d327c1c08dc126f1afe69481e0e242dfda54fe10e975f83e09
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: a581cc5b0d46d8f5ecc6506a890f3fd5a0a36118093951613da9e82c312273c0
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: a4fd63d2ec145a2deb698110f5525902495f6c5d443f8222d579f399df6c3b197c8aec40d50afe6fc77ae66156a3276c6b28143f731444152d871e5c59ad3340
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: c9fb8423892642e93c01c6685f92a2e2ec1bdf3275b8965643b92f985988fe85700273851b8a6ebb5a57132b3f1628146fa162e2a087cf96b9c36e739b175d43
         
     | 
    
        data/CHANGELOG.md
    CHANGED
    
    | 
         @@ -1,3 +1,73 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ## Rails 7.0.8.6 (October 23, 2024) ##
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            *   No changes.
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            ## Rails 7.0.8.5 (October 15, 2024) ##
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            *   No changes.
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            ## Rails 7.0.8.4 (June 04, 2024) ##
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            *   No changes.
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            ## Rails 7.0.8.3 (May 17, 2024) ##
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            *   No changes.
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
            ## Rails 7.0.8.2 (May 16, 2024) ##
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            *   No changes.
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
            ## Rails 7.0.8.1 (February 21, 2024) ##
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
            *   No changes.
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
            ## Rails 7.0.8 (September 09, 2023) ##
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
            *   No changes.
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
            ## Rails 7.0.7.2 (August 22, 2023) ##
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
            *   No changes.
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
            ## Rails 7.0.7.1 (August 22, 2023) ##
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
            *   No changes.
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
            ## Rails 7.0.7 (August 09, 2023) ##
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
            *   Error.full_message now strips ":base" from the message.
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
                *zzak*
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
            *   Add a load hook for `ActiveModel::Model` (named `active_model`) to match the load hook for
         
     | 
| 
      
 53 
     | 
    
         
            +
                `ActiveRecord::Base` and allow for overriding aspects of the `ActiveModel::Model` class.
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
            ## Rails 7.0.6 (June 29, 2023) ##
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
            *   No changes.
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
            ## Rails 7.0.5.1 (June 26, 2023) ##
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
            *   No changes.
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
            ## Rails 7.0.5 (May 24, 2023) ##
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
            *   No changes.
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
       1 
71 
     | 
    
         
             
            ## Rails 7.0.4.3 (March 13, 2023) ##
         
     | 
| 
       2 
72 
     | 
    
         | 
| 
       3 
73 
     | 
    
         
             
            *   No changes.
         
     | 
    
        data/README.rdoc
    CHANGED
    
    | 
         @@ -239,7 +239,7 @@ The latest version of Active Model can be installed with RubyGems: 
     | 
|
| 
       239 
239 
     | 
    
         | 
| 
       240 
240 
     | 
    
         
             
              $ gem install activemodel
         
     | 
| 
       241 
241 
     | 
    
         | 
| 
       242 
     | 
    
         
            -
            Source code can be downloaded as part of the Rails project on GitHub
         
     | 
| 
      
 242 
     | 
    
         
            +
            Source code can be downloaded as part of the \Rails project on GitHub
         
     | 
| 
       243 
243 
     | 
    
         | 
| 
       244 
244 
     | 
    
         
             
            * https://github.com/rails/rails/tree/main/activemodel
         
     | 
| 
       245 
245 
     | 
    
         | 
| 
         @@ -257,7 +257,7 @@ API documentation is at: 
     | 
|
| 
       257 
257 
     | 
    
         | 
| 
       258 
258 
     | 
    
         
             
            * https://api.rubyonrails.org
         
     | 
| 
       259 
259 
     | 
    
         | 
| 
       260 
     | 
    
         
            -
            Bug reports for the Ruby on Rails project can be filed here:
         
     | 
| 
      
 260 
     | 
    
         
            +
            Bug reports for the Ruby on \Rails project can be filed here:
         
     | 
| 
       261 
261 
     | 
    
         | 
| 
       262 
262 
     | 
    
         
             
            * https://github.com/rails/rails/issues
         
     | 
| 
       263 
263 
     | 
    
         | 
| 
         @@ -49,18 +49,17 @@ module ActiveModel 
     | 
|
| 
       49 
49 
     | 
    
         
             
              #     end
         
     | 
| 
       50 
50 
     | 
    
         
             
              #
         
     | 
| 
       51 
51 
     | 
    
         
             
              #     private
         
     | 
| 
      
 52 
     | 
    
         
            +
              #       def attribute_contrived?(attr)
         
     | 
| 
      
 53 
     | 
    
         
            +
              #         true
         
     | 
| 
      
 54 
     | 
    
         
            +
              #       end
         
     | 
| 
       52 
55 
     | 
    
         
             
              #
         
     | 
| 
       53 
     | 
    
         
            -
              # 
     | 
| 
       54 
     | 
    
         
            -
              # 
     | 
| 
       55 
     | 
    
         
            -
              # 
     | 
| 
       56 
     | 
    
         
            -
              #
         
     | 
| 
       57 
     | 
    
         
            -
              #     def clear_attribute(attr)
         
     | 
| 
       58 
     | 
    
         
            -
              #       send("#{attr}=", nil)
         
     | 
| 
       59 
     | 
    
         
            -
              #     end
         
     | 
| 
      
 56 
     | 
    
         
            +
              #       def clear_attribute(attr)
         
     | 
| 
      
 57 
     | 
    
         
            +
              #         send("#{attr}=", nil)
         
     | 
| 
      
 58 
     | 
    
         
            +
              #       end
         
     | 
| 
       60 
59 
     | 
    
         
             
              #
         
     | 
| 
       61 
     | 
    
         
            -
              # 
     | 
| 
       62 
     | 
    
         
            -
              # 
     | 
| 
       63 
     | 
    
         
            -
              # 
     | 
| 
      
 60 
     | 
    
         
            +
              #       def reset_attribute_to_default!(attr)
         
     | 
| 
      
 61 
     | 
    
         
            +
              #         send("#{attr}=", 'Default Name')
         
     | 
| 
      
 62 
     | 
    
         
            +
              #       end
         
     | 
| 
       64 
63 
     | 
    
         
             
              #   end
         
     | 
| 
       65 
64 
     | 
    
         
             
              module AttributeMethods
         
     | 
| 
       66 
65 
     | 
    
         
             
                extend ActiveSupport::Concern
         
     | 
| 
         @@ -95,10 +94,9 @@ module ActiveModel 
     | 
|
| 
       95 
94 
     | 
    
         
             
                  #     define_attribute_methods :name
         
     | 
| 
       96 
95 
     | 
    
         
             
                  #
         
     | 
| 
       97 
96 
     | 
    
         
             
                  #     private
         
     | 
| 
       98 
     | 
    
         
            -
                  #
         
     | 
| 
       99 
     | 
    
         
            -
                  # 
     | 
| 
       100 
     | 
    
         
            -
                  #        
     | 
| 
       101 
     | 
    
         
            -
                  #     end
         
     | 
| 
      
 97 
     | 
    
         
            +
                  #       def clear_attribute(attr)
         
     | 
| 
      
 98 
     | 
    
         
            +
                  #         send("#{attr}=", nil)
         
     | 
| 
      
 99 
     | 
    
         
            +
                  #       end
         
     | 
| 
       102 
100 
     | 
    
         
             
                  #   end
         
     | 
| 
       103 
101 
     | 
    
         
             
                  #
         
     | 
| 
       104 
102 
     | 
    
         
             
                  #   person = Person.new
         
     | 
| 
         @@ -131,10 +129,9 @@ module ActiveModel 
     | 
|
| 
       131 
129 
     | 
    
         
             
                  #     define_attribute_methods :name
         
     | 
| 
       132 
130 
     | 
    
         
             
                  #
         
     | 
| 
       133 
131 
     | 
    
         
             
                  #     private
         
     | 
| 
       134 
     | 
    
         
            -
                  #
         
     | 
| 
       135 
     | 
    
         
            -
                  # 
     | 
| 
       136 
     | 
    
         
            -
                  #        
     | 
| 
       137 
     | 
    
         
            -
                  #     end
         
     | 
| 
      
 132 
     | 
    
         
            +
                  #       def attribute_short?(attr)
         
     | 
| 
      
 133 
     | 
    
         
            +
                  #         send(attr).length < 5
         
     | 
| 
      
 134 
     | 
    
         
            +
                  #       end
         
     | 
| 
       138 
135 
     | 
    
         
             
                  #   end
         
     | 
| 
       139 
136 
     | 
    
         
             
                  #
         
     | 
| 
       140 
137 
     | 
    
         
             
                  #   person = Person.new
         
     | 
| 
         @@ -167,10 +164,9 @@ module ActiveModel 
     | 
|
| 
       167 
164 
     | 
    
         
             
                  #     define_attribute_methods :name
         
     | 
| 
       168 
165 
     | 
    
         
             
                  #
         
     | 
| 
       169 
166 
     | 
    
         
             
                  #     private
         
     | 
| 
       170 
     | 
    
         
            -
                  #
         
     | 
| 
       171 
     | 
    
         
            -
                  # 
     | 
| 
       172 
     | 
    
         
            -
                  #        
     | 
| 
       173 
     | 
    
         
            -
                  #     end
         
     | 
| 
      
 167 
     | 
    
         
            +
                  #       def reset_attribute_to_default!(attr)
         
     | 
| 
      
 168 
     | 
    
         
            +
                  #         send("#{attr}=", 'Default Name')
         
     | 
| 
      
 169 
     | 
    
         
            +
                  #       end
         
     | 
| 
       174 
170 
     | 
    
         
             
                  #   end
         
     | 
| 
       175 
171 
     | 
    
         
             
                  #
         
     | 
| 
       176 
172 
     | 
    
         
             
                  #   person = Person.new
         
     | 
| 
         @@ -194,10 +190,9 @@ module ActiveModel 
     | 
|
| 
       194 
190 
     | 
    
         
             
                  #     alias_attribute :nickname, :name
         
     | 
| 
       195 
191 
     | 
    
         
             
                  #
         
     | 
| 
       196 
192 
     | 
    
         
             
                  #     private
         
     | 
| 
       197 
     | 
    
         
            -
                  #
         
     | 
| 
       198 
     | 
    
         
            -
                  # 
     | 
| 
       199 
     | 
    
         
            -
                  #        
     | 
| 
       200 
     | 
    
         
            -
                  #     end
         
     | 
| 
      
 193 
     | 
    
         
            +
                  #       def attribute_short?(attr)
         
     | 
| 
      
 194 
     | 
    
         
            +
                  #         send(attr).length < 5
         
     | 
| 
      
 195 
     | 
    
         
            +
                  #       end
         
     | 
| 
       201 
196 
     | 
    
         
             
                  #   end
         
     | 
| 
       202 
197 
     | 
    
         
             
                  #
         
     | 
| 
       203 
198 
     | 
    
         
             
                  #   person = Person.new
         
     | 
| 
         @@ -268,10 +263,9 @@ module ActiveModel 
     | 
|
| 
       268 
263 
     | 
    
         
             
                  #     define_attribute_methods :name, :age, :address
         
     | 
| 
       269 
264 
     | 
    
         
             
                  #
         
     | 
| 
       270 
265 
     | 
    
         
             
                  #     private
         
     | 
| 
       271 
     | 
    
         
            -
                  #
         
     | 
| 
       272 
     | 
    
         
            -
                  # 
     | 
| 
       273 
     | 
    
         
            -
                  #        
     | 
| 
       274 
     | 
    
         
            -
                  #     end
         
     | 
| 
      
 266 
     | 
    
         
            +
                  #       def clear_attribute(attr)
         
     | 
| 
      
 267 
     | 
    
         
            +
                  #         send("#{attr}=", nil)
         
     | 
| 
      
 268 
     | 
    
         
            +
                  #       end
         
     | 
| 
       275 
269 
     | 
    
         
             
                  #   end
         
     | 
| 
       276 
270 
     | 
    
         
             
                  def define_attribute_methods(*attr_names)
         
     | 
| 
       277 
271 
     | 
    
         
             
                    ActiveSupport::CodeGenerator.batch(generated_attribute_methods, __FILE__, __LINE__) do |owner|
         
     | 
| 
         @@ -298,10 +292,9 @@ module ActiveModel 
     | 
|
| 
       298 
292 
     | 
    
         
             
                  #     define_attribute_method :name
         
     | 
| 
       299 
293 
     | 
    
         
             
                  #
         
     | 
| 
       300 
294 
     | 
    
         
             
                  #     private
         
     | 
| 
       301 
     | 
    
         
            -
                  #
         
     | 
| 
       302 
     | 
    
         
            -
                  # 
     | 
| 
       303 
     | 
    
         
            -
                  #        
     | 
| 
       304 
     | 
    
         
            -
                  #     end
         
     | 
| 
      
 295 
     | 
    
         
            +
                  #       def attribute_short?(attr)
         
     | 
| 
      
 296 
     | 
    
         
            +
                  #         send(attr).length < 5
         
     | 
| 
      
 297 
     | 
    
         
            +
                  #       end
         
     | 
| 
       305 
298 
     | 
    
         
             
                  #   end
         
     | 
| 
       306 
299 
     | 
    
         
             
                  #
         
     | 
| 
       307 
300 
     | 
    
         
             
                  #   person = Person.new
         
     | 
| 
         @@ -337,10 +330,9 @@ module ActiveModel 
     | 
|
| 
       337 
330 
     | 
    
         
             
                  #     define_attribute_method :name
         
     | 
| 
       338 
331 
     | 
    
         
             
                  #
         
     | 
| 
       339 
332 
     | 
    
         
             
                  #     private
         
     | 
| 
       340 
     | 
    
         
            -
                  #
         
     | 
| 
       341 
     | 
    
         
            -
                  # 
     | 
| 
       342 
     | 
    
         
            -
                  #        
     | 
| 
       343 
     | 
    
         
            -
                  #     end
         
     | 
| 
      
 333 
     | 
    
         
            +
                  #       def attribute_short?(attr)
         
     | 
| 
      
 334 
     | 
    
         
            +
                  #         send(attr).length < 5
         
     | 
| 
      
 335 
     | 
    
         
            +
                  #       end
         
     | 
| 
       344 
336 
     | 
    
         
             
                  #   end
         
     | 
| 
       345 
337 
     | 
    
         
             
                  #
         
     | 
| 
       346 
338 
     | 
    
         
             
                  #   person = Person.new
         
     | 
| 
         @@ -423,7 +415,7 @@ module ActiveModel 
     | 
|
| 
       423 
415 
     | 
    
         
             
                        @prefix = prefix
         
     | 
| 
       424 
416 
     | 
    
         
             
                        @suffix = suffix
         
     | 
| 
       425 
417 
     | 
    
         
             
                        @parameters = parameters.nil? ? FORWARD_PARAMETERS : parameters
         
     | 
| 
       426 
     | 
    
         
            -
                        @regex =  
     | 
| 
      
 418 
     | 
    
         
            +
                        @regex = /\A(?:#{Regexp.escape(@prefix)})(.*)(?:#{Regexp.escape(@suffix)})\z/
         
     | 
| 
       427 
419 
     | 
    
         
             
                        @target = "#{@prefix}attribute#{@suffix}"
         
     | 
| 
       428 
420 
     | 
    
         
             
                        @method_name = "#{prefix}%s#{suffix}"
         
     | 
| 
       429 
421 
     | 
    
         
             
                      end
         
     | 
| 
         @@ -43,8 +43,8 @@ module ActiveModel 
     | 
|
| 
       43 
43 
     | 
    
         | 
| 
       44 
44 
     | 
    
         
             
                def changed?(attr_name, from: OPTION_NOT_GIVEN, to: OPTION_NOT_GIVEN)
         
     | 
| 
       45 
45 
     | 
    
         
             
                  attribute_changed?(attr_name) &&
         
     | 
| 
       46 
     | 
    
         
            -
                    (OPTION_NOT_GIVEN == from || original_value(attr_name) == from) &&
         
     | 
| 
       47 
     | 
    
         
            -
                    (OPTION_NOT_GIVEN == to || fetch_value(attr_name) == to)
         
     | 
| 
      
 46 
     | 
    
         
            +
                    (OPTION_NOT_GIVEN == from || original_value(attr_name) == type_cast(attr_name, from)) &&
         
     | 
| 
      
 47 
     | 
    
         
            +
                    (OPTION_NOT_GIVEN == to || fetch_value(attr_name) == type_cast(attr_name, to))
         
     | 
| 
       48 
48 
     | 
    
         
             
                end
         
     | 
| 
       49 
49 
     | 
    
         | 
| 
       50 
50 
     | 
    
         
             
                def changed_in_place?(attr_name)
         
     | 
| 
         @@ -82,6 +82,10 @@ module ActiveModel 
     | 
|
| 
       82 
82 
     | 
    
         
             
                  def fetch_value(attr_name)
         
     | 
| 
       83 
83 
     | 
    
         
             
                    attributes.fetch_value(attr_name)
         
     | 
| 
       84 
84 
     | 
    
         
             
                  end
         
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
      
 86 
     | 
    
         
            +
                  def type_cast(attr_name, value)
         
     | 
| 
      
 87 
     | 
    
         
            +
                    attributes[attr_name].type_cast(value)
         
     | 
| 
      
 88 
     | 
    
         
            +
                  end
         
     | 
| 
       85 
89 
     | 
    
         
             
              end
         
     | 
| 
       86 
90 
     | 
    
         | 
| 
       87 
91 
     | 
    
         
             
              class ForcedMutationTracker < AttributeMutationTracker # :nodoc:
         
     | 
| 
         @@ -143,6 +147,10 @@ module ActiveModel 
     | 
|
| 
       143 
147 
     | 
    
         
             
                  rescue TypeError, NoMethodError
         
     | 
| 
       144 
148 
     | 
    
         
             
                    value
         
     | 
| 
       145 
149 
     | 
    
         
             
                  end
         
     | 
| 
      
 150 
     | 
    
         
            +
             
     | 
| 
      
 151 
     | 
    
         
            +
                  def type_cast(attr_name, value)
         
     | 
| 
      
 152 
     | 
    
         
            +
                    value
         
     | 
| 
      
 153 
     | 
    
         
            +
                  end
         
     | 
| 
       146 
154 
     | 
    
         
             
              end
         
     | 
| 
       147 
155 
     | 
    
         | 
| 
       148 
156 
     | 
    
         
             
              class NullMutationTracker # :nodoc:
         
     | 
| 
         @@ -74,7 +74,7 @@ module ActiveModel 
     | 
|
| 
       74 
74 
     | 
    
         
             
                # <tt>:only</tt> option, where you can choose if you want all types (before,
         
     | 
| 
       75 
75 
     | 
    
         
             
                # around or after) or just some.
         
     | 
| 
       76 
76 
     | 
    
         
             
                #
         
     | 
| 
       77 
     | 
    
         
            -
                #   define_model_callbacks : 
     | 
| 
      
 77 
     | 
    
         
            +
                #   define_model_callbacks :initialize, only: :after
         
     | 
| 
       78 
78 
     | 
    
         
             
                #
         
     | 
| 
       79 
79 
     | 
    
         
             
                # Note, the <tt>only: <type></tt> hash will apply to all callbacks defined
         
     | 
| 
       80 
80 
     | 
    
         
             
                # on that method call. To get around this you can call the define_model_callbacks
         
     | 
    
        data/lib/active_model/error.rb
    CHANGED
    
    | 
         @@ -49,7 +49,7 @@ module ActiveModel 
     | 
|
| 
       49 
49 
     | 
    
         
             
                  defaults << :"errors.format"
         
     | 
| 
       50 
50 
     | 
    
         
             
                  defaults << "%{attribute} %{message}"
         
     | 
| 
       51 
51 
     | 
    
         | 
| 
       52 
     | 
    
         
            -
                  attr_name = attribute.tr(".", "_").humanize
         
     | 
| 
      
 52 
     | 
    
         
            +
                  attr_name = attribute.remove(/\.base\z/).tr(".", "_").humanize
         
     | 
| 
       53 
53 
     | 
    
         
             
                  attr_name = base_class.human_attribute_name(attribute, {
         
     | 
| 
       54 
54 
     | 
    
         
             
                    default: attr_name,
         
     | 
| 
       55 
55 
     | 
    
         
             
                    base: base,
         
     | 
| 
         @@ -15,7 +15,9 @@ module ActiveModel 
     | 
|
| 
       15 
15 
     | 
    
         
             
                    if value.is_a?(Data)
         
     | 
| 
       16 
16 
     | 
    
         
             
                      value.to_s
         
     | 
| 
       17 
17 
     | 
    
         
             
                    else
         
     | 
| 
       18 
     | 
    
         
            -
                      super
         
     | 
| 
      
 18 
     | 
    
         
            +
                      value = super
         
     | 
| 
      
 19 
     | 
    
         
            +
                      value = value.b if ::String === value && value.encoding != Encoding::BINARY
         
     | 
| 
      
 20 
     | 
    
         
            +
                      value
         
     | 
| 
       19 
21 
     | 
    
         
             
                    end
         
     | 
| 
       20 
22 
     | 
    
         
             
                  end
         
     | 
| 
       21 
23 
     | 
    
         | 
| 
         @@ -31,7 +33,9 @@ module ActiveModel 
     | 
|
| 
       31 
33 
     | 
    
         | 
| 
       32 
34 
     | 
    
         
             
                  class Data # :nodoc:
         
     | 
| 
       33 
35 
     | 
    
         
             
                    def initialize(value)
         
     | 
| 
       34 
     | 
    
         
            -
                       
     | 
| 
      
 36 
     | 
    
         
            +
                      value = value.to_s
         
     | 
| 
      
 37 
     | 
    
         
            +
                      value = value.b unless value.encoding == Encoding::BINARY
         
     | 
| 
      
 38 
     | 
    
         
            +
                      @value = value
         
     | 
| 
       35 
39 
     | 
    
         
             
                    end
         
     | 
| 
       36 
40 
     | 
    
         | 
| 
       37 
41 
     | 
    
         
             
                    def to_s
         
     | 
| 
         @@ -121,6 +121,14 @@ module ActiveModel 
     | 
|
| 
       121 
121 
     | 
    
         
             
                  def assert_valid_value(_)
         
     | 
| 
       122 
122 
     | 
    
         
             
                  end
         
     | 
| 
       123 
123 
     | 
    
         | 
| 
      
 124 
     | 
    
         
            +
                  def serialized? # :nodoc:
         
     | 
| 
      
 125 
     | 
    
         
            +
                    false
         
     | 
| 
      
 126 
     | 
    
         
            +
                  end
         
     | 
| 
      
 127 
     | 
    
         
            +
             
     | 
| 
      
 128 
     | 
    
         
            +
                  def mutable? # :nodoc:
         
     | 
| 
      
 129 
     | 
    
         
            +
                    false
         
     | 
| 
      
 130 
     | 
    
         
            +
                  end
         
     | 
| 
      
 131 
     | 
    
         
            +
             
     | 
| 
       124 
132 
     | 
    
         
             
                  private
         
     | 
| 
       125 
133 
     | 
    
         
             
                    # Convenience method for types which do not need separate type casting
         
     | 
| 
       126 
134 
     | 
    
         
             
                    # behavior for user and database inputs. Called by Value#cast for
         
     | 
| 
         @@ -43,10 +43,9 @@ module ActiveModel 
     | 
|
| 
       43 
43 
     | 
    
         
             
                    #     before_validation :remove_whitespaces
         
     | 
| 
       44 
44 
     | 
    
         
             
                    #
         
     | 
| 
       45 
45 
     | 
    
         
             
                    #     private
         
     | 
| 
       46 
     | 
    
         
            -
                    #
         
     | 
| 
       47 
     | 
    
         
            -
                    # 
     | 
| 
       48 
     | 
    
         
            -
                    #        
     | 
| 
       49 
     | 
    
         
            -
                    #     end
         
     | 
| 
      
 46 
     | 
    
         
            +
                    #       def remove_whitespaces
         
     | 
| 
      
 47 
     | 
    
         
            +
                    #         name.strip!
         
     | 
| 
      
 48 
     | 
    
         
            +
                    #       end
         
     | 
| 
       50 
49 
     | 
    
         
             
                    #   end
         
     | 
| 
       51 
50 
     | 
    
         
             
                    #
         
     | 
| 
       52 
51 
     | 
    
         
             
                    #   person = Person.new
         
     | 
| 
         @@ -74,10 +73,9 @@ module ActiveModel 
     | 
|
| 
       74 
73 
     | 
    
         
             
                    #     after_validation :set_status
         
     | 
| 
       75 
74 
     | 
    
         
             
                    #
         
     | 
| 
       76 
75 
     | 
    
         
             
                    #     private
         
     | 
| 
       77 
     | 
    
         
            -
                    #
         
     | 
| 
       78 
     | 
    
         
            -
                    # 
     | 
| 
       79 
     | 
    
         
            -
                    #        
     | 
| 
       80 
     | 
    
         
            -
                    #     end
         
     | 
| 
      
 76 
     | 
    
         
            +
                    #       def set_status
         
     | 
| 
      
 77 
     | 
    
         
            +
                    #         self.status = errors.empty?
         
     | 
| 
      
 78 
     | 
    
         
            +
                    #       end
         
     | 
| 
       81 
79 
     | 
    
         
             
                    #   end
         
     | 
| 
       82 
80 
     | 
    
         
             
                    #
         
     | 
| 
       83 
81 
     | 
    
         
             
                    #   person = Person.new
         
     | 
| 
         @@ -85,10 +85,9 @@ module ActiveModel 
     | 
|
| 
       85 
85 
     | 
    
         
             
                  #     validates_length_of :words_in_essay, minimum: 100, too_short: 'Your essay must be at least 100 words.'
         
     | 
| 
       86 
86 
     | 
    
         
             
                  #
         
     | 
| 
       87 
87 
     | 
    
         
             
                  #     private
         
     | 
| 
       88 
     | 
    
         
            -
                  #
         
     | 
| 
       89 
     | 
    
         
            -
                  # 
     | 
| 
       90 
     | 
    
         
            -
                  #        
     | 
| 
       91 
     | 
    
         
            -
                  #     end
         
     | 
| 
      
 88 
     | 
    
         
            +
                  #       def words_in_essay
         
     | 
| 
      
 89 
     | 
    
         
            +
                  #         essay.scan(/\w+/)
         
     | 
| 
      
 90 
     | 
    
         
            +
                  #       end
         
     | 
| 
       92 
91 
     | 
    
         
             
                  #   end
         
     | 
| 
       93 
92 
     | 
    
         
             
                  #
         
     | 
| 
       94 
93 
     | 
    
         
             
                  # Constraint options:
         
     | 
| 
         @@ -96,7 +96,7 @@ module ActiveModel 
     | 
|
| 
       96 
96 
     | 
    
         
             
                  # Example:
         
     | 
| 
       97 
97 
     | 
    
         
             
                  #
         
     | 
| 
       98 
98 
     | 
    
         
             
                  #   validates :password, presence: true, confirmation: true, if: :password_required?
         
     | 
| 
       99 
     | 
    
         
            -
                  #   validates :token, length: 24, strict: TokenLengthException
         
     | 
| 
      
 99 
     | 
    
         
            +
                  #   validates :token, length: { is: 24 }, strict: TokenLengthException
         
     | 
| 
       100 
100 
     | 
    
         
             
                  #
         
     | 
| 
       101 
101 
     | 
    
         
             
                  #
         
     | 
| 
       102 
102 
     | 
    
         
             
                  # Finally, the options +:if+, +:unless+, +:on+, +:allow_blank+, +:allow_nil+, +:strict+
         
     | 
    
        data/lib/active_model.rb
    CHANGED
    
    | 
         @@ -58,6 +58,7 @@ module ActiveModel 
     | 
|
| 
       58 
58 
     | 
    
         
             
                autoload :RangeError, "active_model/errors"
         
     | 
| 
       59 
59 
     | 
    
         
             
                autoload :StrictValidationFailed, "active_model/errors"
         
     | 
| 
       60 
60 
     | 
    
         
             
                autoload :UnknownAttributeError, "active_model/errors"
         
     | 
| 
      
 61 
     | 
    
         
            +
                autoload :ValidationError, "active_model/validations"
         
     | 
| 
       61 
62 
     | 
    
         
             
              end
         
     | 
| 
       62 
63 
     | 
    
         | 
| 
       63 
64 
     | 
    
         
             
              module Serializers
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: activemodel
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 7.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 7.0.8.6
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - David Heinemeier Hansson
         
     | 
| 
       8 
     | 
    
         
            -
            autorequire:
         
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date:  
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2024-10-23 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: activesupport
         
     | 
| 
         @@ -16,14 +16,14 @@ dependencies: 
     | 
|
| 
       16 
16 
     | 
    
         
             
                requirements:
         
     | 
| 
       17 
17 
     | 
    
         
             
                - - '='
         
     | 
| 
       18 
18 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       19 
     | 
    
         
            -
                    version: 7.0. 
     | 
| 
      
 19 
     | 
    
         
            +
                    version: 7.0.8.6
         
     | 
| 
       20 
20 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       21 
21 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       22 
22 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       23 
23 
     | 
    
         
             
                requirements:
         
     | 
| 
       24 
24 
     | 
    
         
             
                - - '='
         
     | 
| 
       25 
25 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       26 
     | 
    
         
            -
                    version: 7.0. 
     | 
| 
      
 26 
     | 
    
         
            +
                    version: 7.0.8.6
         
     | 
| 
       27 
27 
     | 
    
         
             
            description: A toolkit for building modeling frameworks like Active Record. Rich support
         
     | 
| 
       28 
28 
     | 
    
         
             
              for attributes, callbacks, validations, serialization, internationalization, and
         
     | 
| 
       29 
29 
     | 
    
         
             
              testing.
         
     | 
| 
         @@ -107,12 +107,12 @@ licenses: 
     | 
|
| 
       107 
107 
     | 
    
         
             
            - MIT
         
     | 
| 
       108 
108 
     | 
    
         
             
            metadata:
         
     | 
| 
       109 
109 
     | 
    
         
             
              bug_tracker_uri: https://github.com/rails/rails/issues
         
     | 
| 
       110 
     | 
    
         
            -
              changelog_uri: https://github.com/rails/rails/blob/v7.0. 
     | 
| 
       111 
     | 
    
         
            -
              documentation_uri: https://api.rubyonrails.org/v7.0. 
     | 
| 
      
 110 
     | 
    
         
            +
              changelog_uri: https://github.com/rails/rails/blob/v7.0.8.6/activemodel/CHANGELOG.md
         
     | 
| 
      
 111 
     | 
    
         
            +
              documentation_uri: https://api.rubyonrails.org/v7.0.8.6/
         
     | 
| 
       112 
112 
     | 
    
         
             
              mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
         
     | 
| 
       113 
     | 
    
         
            -
              source_code_uri: https://github.com/rails/rails/tree/v7.0. 
     | 
| 
      
 113 
     | 
    
         
            +
              source_code_uri: https://github.com/rails/rails/tree/v7.0.8.6/activemodel
         
     | 
| 
       114 
114 
     | 
    
         
             
              rubygems_mfa_required: 'true'
         
     | 
| 
       115 
     | 
    
         
            -
            post_install_message:
         
     | 
| 
      
 115 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
       116 
116 
     | 
    
         
             
            rdoc_options: []
         
     | 
| 
       117 
117 
     | 
    
         
             
            require_paths:
         
     | 
| 
       118 
118 
     | 
    
         
             
            - lib
         
     | 
| 
         @@ -127,8 +127,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       127 
127 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       128 
128 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       129 
129 
     | 
    
         
             
            requirements: []
         
     | 
| 
       130 
     | 
    
         
            -
            rubygems_version: 3. 
     | 
| 
       131 
     | 
    
         
            -
            signing_key:
         
     | 
| 
      
 130 
     | 
    
         
            +
            rubygems_version: 3.5.16
         
     | 
| 
      
 131 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
       132 
132 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       133 
133 
     | 
    
         
             
            summary: A toolkit for building modeling frameworks (part of Rails).
         
     | 
| 
       134 
134 
     | 
    
         
             
            test_files: []
         
     |