rails_string_enum 0.3.2 → 0.4.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/README.md +4 -0
 - data/lib/rails_string_enum/string_enum.rb +11 -0
 - data/lib/rails_string_enum/version.rb +1 -1
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 6ffcc890f6854d7a23813243d6497693855a9708
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 466bc0454e0e761ead3fc71a58062b523cd4f281
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 2e3323198397858722fd5a24a24c6b11c79803ec2aca9c09ad2b101956e614f23a94038fe4361718bc230decb55df27cefa1410495b0c959d15773b53d44838f
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: dbe2ad31026fd97e4cb99de452e7ab4e0832034f61ff7f632897b69c3a3ac4c01ed2a70f3022a8dbe4f67f8124132a54fe8339802d932fb339d1c6c1e10df1d4
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -86,6 +86,10 @@ Product::COLORS # => ["red", "green", "yellow"] 
     | 
|
| 
       86 
86 
     | 
    
         
             
            Product::RED # => "red"
         
     | 
| 
       87 
87 
     | 
    
         
             
            Product::GREEN # => "green"
         
     | 
| 
       88 
88 
     | 
    
         | 
| 
      
 89 
     | 
    
         
            +
            # for combinations constants to array, using `__` for split it
         
     | 
| 
      
 90 
     | 
    
         
            +
            Product::RED__GREEN__YELLOW #=> ["red", "green", "yellow"]
         
     | 
| 
      
 91 
     | 
    
         
            +
            Product::RED__GREEN__BLABLA #=> NameError: uninitialized constant Product::BLABLA
         
     | 
| 
      
 92 
     | 
    
         
            +
             
     | 
| 
       89 
93 
     | 
    
         
             
            @product = Product.new
         
     | 
| 
       90 
94 
     | 
    
         
             
            @product.color_i18n  # => nil
         
     | 
| 
       91 
95 
     | 
    
         
             
            @product.red!
         
     | 
| 
         @@ -127,4 +127,15 @@ module RailsStringEnum 
     | 
|
| 
       127 
127 
     | 
    
         
             
                %Q{::I18n.t(enum_label, scope: "enums.#{part_scope}", default: enum_label)}
         
     | 
| 
       128 
128 
     | 
    
         
             
              end
         
     | 
| 
       129 
129 
     | 
    
         | 
| 
      
 130 
     | 
    
         
            +
             
     | 
| 
      
 131 
     | 
    
         
            +
              # for combinations constants to array, using `__` for split it
         
     | 
| 
      
 132 
     | 
    
         
            +
              # Product::RED__GREEN__YELLOW #=> ["red", "green", "yellow"]
         
     | 
| 
      
 133 
     | 
    
         
            +
              # Product::RED__GREEN__BLABLA #=> NameError: uninitialized constant Product::BLABLA
         
     | 
| 
      
 134 
     | 
    
         
            +
              def const_missing(name)
         
     | 
| 
      
 135 
     | 
    
         
            +
                name_s = name.to_s
         
     | 
| 
      
 136 
     | 
    
         
            +
                return super unless name_s.include?('__')
         
     | 
| 
      
 137 
     | 
    
         
            +
             
     | 
| 
      
 138 
     | 
    
         
            +
                const_set name_s, name_s.split('__').map { |i| const_get(i) }
         
     | 
| 
      
 139 
     | 
    
         
            +
              end
         
     | 
| 
      
 140 
     | 
    
         
            +
             
     | 
| 
       130 
141 
     | 
    
         
             
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: rails_string_enum
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.4.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - ermolaev
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: exe
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2015- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2015-09-14 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: bundler
         
     |