power_enum 4.0.1 → 4.2.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 +4 -4
 - data/VERSION +1 -1
 - data/lib/active_record/virtual_enumerations.rb +2 -0
 - data/lib/generators/enum/enum_generator.rb +2 -0
 - data/lib/generators/enum/enum_generator_helpers/migration_number.rb +4 -1
 - data/lib/generators/virtual_enumerations_initializer/virtual_enumerations_initializer_generator.rb +3 -1
 - data/lib/power_enum/enumerated.rb +2 -0
 - data/lib/power_enum/has_enumerated.rb +3 -1
 - data/lib/power_enum/migration/command_recorder.rb +3 -1
 - data/lib/power_enum/reflection.rb +6 -1
 - data/lib/power_enum/schema/schema_statements.rb +12 -4
 - data/lib/power_enum.rb +2 -0
 - data/lib/testing/rspec.rb +4 -2
 - metadata +6 -6
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 35edbdb441b395299aa1f20a3719b5be76944f65eece54831eae69b3ffb57a9a
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: c4a2ce79baaa5bf26e056f1e4ab2470a34d40c0456931850c0b9c4ca5c5580ff
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 025f11e5861f9e3a0fd9d0f5dc2d547944ae4dac506432d1e08eee1afe4117b359e41c93962006c94e3c05ced183b7c733d0681e8e0a35a7cccfdab7d0afb3f2
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 744d9fecff6322d6faab40418ebac2d438b8140c2363b23fe20a5cfc4813002c0f3b85788849f4c4e65c86128eaa711d3f8b8d6bdc895291f5731223fb4d2529
         
     | 
    
        data/VERSION
    CHANGED
    
    | 
         @@ -1 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            4.0 
     | 
| 
      
 1 
     | 
    
         
            +
            4.2.0
         
     | 
| 
         @@ -1,3 +1,5 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            # Helper logic for the enum generator
         
     | 
| 
       2 
4 
     | 
    
         
             
            module EnumGeneratorHelpers
         
     | 
| 
       3 
5 
     | 
    
         
             
              # Helper methods to figure out the migration number.
         
     | 
| 
         @@ -9,7 +11,8 @@ module EnumGeneratorHelpers 
     | 
|
| 
       9 
11 
     | 
    
         
             
                  # Lifted directly from ActiveRecord::Generators::Migration
         
     | 
| 
       10 
12 
     | 
    
         
             
                  # Unfortunately, no API is provided by Rails at this time.
         
     | 
| 
       11 
13 
     | 
    
         
             
                  next_migration_number = current_migration_number(dirname) + 1
         
     | 
| 
       12 
     | 
    
         
            -
                  if ActiveRecord::Base.timestamped_migrations
         
     | 
| 
      
 14 
     | 
    
         
            +
                  if (ActiveRecord::Base.respond_to?(:timestamped_migrations) && ActiveRecord::Base.timestamped_migrations) ||
         
     | 
| 
      
 15 
     | 
    
         
            +
                     (ActiveRecord.respond_to?(:timestamped_migrations) && ActiveRecord.timestamped_migrations) # Changed in Rails 7.1
         
     | 
| 
       13 
16 
     | 
    
         
             
                    [Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max
         
     | 
| 
       14 
17 
     | 
    
         
             
                  else
         
     | 
| 
       15 
18 
     | 
    
         
             
                    "%.3d" % next_migration_number
         
     | 
    
        data/lib/generators/virtual_enumerations_initializer/virtual_enumerations_initializer_generator.rb
    CHANGED
    
    | 
         @@ -1,3 +1,5 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            # Copyright (c) 2011 Arthur Shagall
         
     | 
| 
       2 
4 
     | 
    
         
             
            # Released under the MIT license.  See LICENSE for details.
         
     | 
| 
       3 
5 
     | 
    
         | 
| 
         @@ -12,4 +14,4 @@ class VirtualEnumerationsInitializerGenerator < Rails::Generators::Base 
     | 
|
| 
       12 
14 
     | 
    
         
             
                template 'virtual_enumerations.rb.erb', "config/initializers/#{initializer_name}.rb"
         
     | 
| 
       13 
15 
     | 
    
         
             
              end
         
     | 
| 
       14 
16 
     | 
    
         | 
| 
       15 
     | 
    
         
            -
            end
         
     | 
| 
      
 17 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -1,3 +1,5 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            # Copyright (c) 2005 Trevor Squires
         
     | 
| 
       2 
4 
     | 
    
         
             
            # Copyright (c) 2012 Arthur Shagall
         
     | 
| 
       3 
5 
     | 
    
         
             
            # Released under the MIT License.  See the LICENSE file for more details.
         
     | 
| 
         @@ -129,7 +131,7 @@ module PowerEnum 
     | 
|
| 
       129 
131 
     | 
    
         
             
                  private def create_ar_reflection(part_id, options)
         
     | 
| 
       130 
132 
     | 
    
         
             
                    reflection = PowerEnum::Reflection::EnumerationReflection.new(part_id, options, self)
         
     | 
| 
       131 
133 
     | 
    
         | 
| 
       132 
     | 
    
         
            -
                    self._reflections = self._reflections.merge(part_id.to_s => reflection)
         
     | 
| 
      
 134 
     | 
    
         
            +
                    self._reflections = self._reflections.merge(part_id.to_s => reflection, part_id.to_sym => reflection)
         
     | 
| 
       133 
135 
     | 
    
         
             
                    reflection
         
     | 
| 
       134 
136 
     | 
    
         
             
                  end
         
     | 
| 
       135 
137 
     | 
    
         | 
| 
         @@ -1,3 +1,5 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            # Copyright (c) 2011 Artem Kuzko
         
     | 
| 
       2 
4 
     | 
    
         
             
            # Copyright (c) 2013 Zach Belzer
         
     | 
| 
       3 
5 
     | 
    
         
             
            # Copyright (c) 2013 Arthur Shagall
         
     | 
| 
         @@ -106,7 +108,7 @@ of these associations is deprecated and will be removed in the future. 
     | 
|
| 
       106 
108 
     | 
    
         
             
                def check_validity!; end
         
     | 
| 
       107 
109 
     | 
    
         | 
| 
       108 
110 
     | 
    
         
             
                # Returns nil
         
     | 
| 
       109 
     | 
    
         
            -
                def source_reflection 
     | 
| 
      
 111 
     | 
    
         
            +
                def source_reflection
         
     | 
| 
       110 
112 
     | 
    
         
             
                  nil
         
     | 
| 
       111 
113 
     | 
    
         
             
                end
         
     | 
| 
       112 
114 
     | 
    
         | 
| 
         @@ -115,6 +117,9 @@ of these associations is deprecated and will be removed in the future. 
     | 
|
| 
       115 
117 
     | 
    
         
             
                  nil
         
     | 
| 
       116 
118 
     | 
    
         
             
                end
         
     | 
| 
       117 
119 
     | 
    
         | 
| 
      
 120 
     | 
    
         
            +
                # https://github.com/rails/rails/pull/48362
         
     | 
| 
      
 121 
     | 
    
         
            +
                alias_method :join_primary_type, :type
         
     | 
| 
      
 122 
     | 
    
         
            +
             
     | 
| 
       118 
123 
     | 
    
         
             
                # Always returns false. Necessary for stuff like Booking.where(:status => BookingStatus[:confirmed])
         
     | 
| 
       119 
124 
     | 
    
         
             
                def polymorphic?
         
     | 
| 
       120 
125 
     | 
    
         
             
                  false
         
     | 
| 
         @@ -1,3 +1,5 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            # Copyright (c) 2011 Arthur Shagall
         
     | 
| 
       2 
4 
     | 
    
         
             
            # Released under the MIT license.  See LICENSE for details.
         
     | 
| 
       3 
5 
     | 
    
         | 
| 
         @@ -7,10 +9,16 @@ module PowerEnum::Schema 
     | 
|
| 
       7 
9 
     | 
    
         
             
              module SchemaStatements
         
     | 
| 
       8 
10 
     | 
    
         | 
| 
       9 
11 
     | 
    
         
             
                def self.included(base) # :nodoc:
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
                     
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                  %w[AbstractAdapter PostgreSQLAdapter].each do |name|
         
     | 
| 
      
 14 
     | 
    
         
            +
                    if base.const_defined?(name)
         
     | 
| 
      
 15 
     | 
    
         
            +
                      base.const_get(name).class_eval do
         
     | 
| 
      
 16 
     | 
    
         
            +
                        # Currently defined in ActiveRecord::ConnectionAdapters::PostgreSQLAdapter#create_enum
         
     | 
| 
      
 17 
     | 
    
         
            +
                        # This squashes the "#create_enum" in the PostgreSQL adapter in Rails 7+.
         
     | 
| 
      
 18 
     | 
    
         
            +
                        # .../activerecord-7.0.X.Y/lib/active_record/connection_adapters/postgresql_adapter.rb
         
     | 
| 
      
 19 
     | 
    
         
            +
                        prepend PowerEnum::Schema::AbstractAdapter
         
     | 
| 
      
 20 
     | 
    
         
            +
                      end
         
     | 
| 
      
 21 
     | 
    
         
            +
                    end
         
     | 
| 
       14 
22 
     | 
    
         
             
                  end
         
     | 
| 
       15 
23 
     | 
    
         
             
                end
         
     | 
| 
       16 
24 
     | 
    
         | 
    
        data/lib/power_enum.rb
    CHANGED
    
    
    
        data/lib/testing/rspec.rb
    CHANGED
    
    | 
         @@ -1,3 +1,5 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            if defined? RSpec
         
     | 
| 
       2 
4 
     | 
    
         
             
              require 'rspec/expectations'
         
     | 
| 
       3 
5 
     | 
    
         | 
| 
         @@ -90,7 +92,7 @@ if defined? RSpec 
     | 
|
| 
       90 
92 
     | 
    
         
             
                failure_message do
         
     | 
| 
       91 
93 
     | 
    
         
             
                  message = "should act as enumerated"
         
     | 
| 
       92 
94 
     | 
    
         
             
                  if @items
         
     | 
| 
       93 
     | 
    
         
            -
                    message  
     | 
| 
      
 95 
     | 
    
         
            +
                    message = "#{message} and have members #{@items.inspect}"
         
     | 
| 
       94 
96 
     | 
    
         
             
                  end
         
     | 
| 
       95 
97 
     | 
    
         
             
                  message
         
     | 
| 
       96 
98 
     | 
    
         
             
                end
         
     | 
| 
         @@ -98,7 +100,7 @@ if defined? RSpec 
     | 
|
| 
       98 
100 
     | 
    
         
             
                failure_message_when_negated do
         
     | 
| 
       99 
101 
     | 
    
         
             
                  message = "should not act as enumerated"
         
     | 
| 
       100 
102 
     | 
    
         
             
                  if @items
         
     | 
| 
       101 
     | 
    
         
            -
                    message  
     | 
| 
      
 103 
     | 
    
         
            +
                    message = "#{message} with members #{@items.inspect}"
         
     | 
| 
       102 
104 
     | 
    
         
             
                  end
         
     | 
| 
       103 
105 
     | 
    
         
             
                  message
         
     | 
| 
       104 
106 
     | 
    
         
             
                end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,17 +1,17 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: power_enum
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 4.0 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 4.2.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Trevor Squires
         
     | 
| 
       8 
8 
     | 
    
         
             
            - Pivotal Labs
         
     | 
| 
       9 
9 
     | 
    
         
             
            - Arthur Shagall
         
     | 
| 
       10 
10 
     | 
    
         
             
            - Sergey Potapov
         
     | 
| 
       11 
     | 
    
         
            -
            autorequire: 
     | 
| 
      
 11 
     | 
    
         
            +
            autorequire:
         
     | 
| 
       12 
12 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       13 
13 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       14 
     | 
    
         
            -
            date:  
     | 
| 
      
 14 
     | 
    
         
            +
            date: 2025-10-24 00:00:00.000000000 Z
         
     | 
| 
       15 
15 
     | 
    
         
             
            dependencies:
         
     | 
| 
       16 
16 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       17 
17 
     | 
    
         
             
              name: bundler
         
     | 
| 
         @@ -151,7 +151,7 @@ homepage: http://github.com/albertosaurus/power_enum_2 
     | 
|
| 
       151 
151 
     | 
    
         
             
            licenses:
         
     | 
| 
       152 
152 
     | 
    
         
             
            - MIT
         
     | 
| 
       153 
153 
     | 
    
         
             
            metadata: {}
         
     | 
| 
       154 
     | 
    
         
            -
            post_install_message: 
     | 
| 
      
 154 
     | 
    
         
            +
            post_install_message:
         
     | 
| 
       155 
155 
     | 
    
         
             
            rdoc_options: []
         
     | 
| 
       156 
156 
     | 
    
         
             
            require_paths:
         
     | 
| 
       157 
157 
     | 
    
         
             
            - lib
         
     | 
| 
         @@ -166,8 +166,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       166 
166 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       167 
167 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       168 
168 
     | 
    
         
             
            requirements: []
         
     | 
| 
       169 
     | 
    
         
            -
            rubygems_version: 3.2. 
     | 
| 
       170 
     | 
    
         
            -
            signing_key: 
     | 
| 
      
 169 
     | 
    
         
            +
            rubygems_version: 3.2.33
         
     | 
| 
      
 170 
     | 
    
         
            +
            signing_key:
         
     | 
| 
       171 
171 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       172 
172 
     | 
    
         
             
            summary: Allows you to treat instances of your ActiveRecord models as though they
         
     | 
| 
       173 
173 
     | 
    
         
             
              were an enumeration of values
         
     |