pluck_all 2.2.1 → 2.3.3
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/.github/workflows/ruby.yml +116 -0
 - data/.gitignore +10 -10
 - data/.rubocop.yml +1227 -1227
 - data/CHANGELOG.md +12 -0
 - data/CODE_OF_CONDUCT.md +48 -48
 - data/LICENSE.txt +21 -21
 - data/README.md +187 -167
 - data/Rakefile +22 -22
 - data/bin/console +14 -14
 - data/bin/setup +8 -8
 - data/gemfiles/active_record_32.gemfile +16 -13
 - data/gemfiles/active_record_42.gemfile +18 -13
 - data/gemfiles/active_record_50.gemfile +18 -13
 - data/gemfiles/active_record_51.gemfile +18 -13
 - data/gemfiles/active_record_52.gemfile +18 -13
 - data/gemfiles/active_record_60.gemfile +18 -13
 - data/gemfiles/active_record_61.gemfile +18 -13
 - data/gemfiles/mongoid_54.gemfile +11 -11
 - data/gemfiles/mongoid_64.gemfile +11 -11
 - data/gemfiles/{mongoid_70.gemfile → mongoid_73.gemfile} +11 -11
 - data/lib/pluck_all/hooks.rb +21 -21
 - data/lib/pluck_all/models/active_record_extension.rb +138 -131
 - data/lib/pluck_all/models/mongoid_extension.rb +88 -70
 - data/lib/pluck_all/models/patches/deserialize.rb +13 -13
 - data/lib/pluck_all/version.rb +4 -4
 - data/lib/pluck_all.rb +3 -3
 - data/pluck_all.gemspec +43 -43
 - metadata +7 -7
 - data/.travis.yml +0 -73
 
| 
         @@ -1,13 +1,18 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            source 'https://rubygems.org'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            # Specify your gem's dependencies in pluck_all.gemspec
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
            gem 'sqlite3',      '~> 1.3.0'
         
     | 
| 
       6 
     | 
    
         
            -
            gem 'activerecord', '~> 4.2.0'
         
     | 
| 
       7 
     | 
    
         
            -
            gem ' 
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            source 'https://rubygems.org'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            # Specify your gem's dependencies in pluck_all.gemspec
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            gem 'sqlite3',      '~> 1.3.0'
         
     | 
| 
      
 6 
     | 
    
         
            +
            gem 'activerecord', '~> 4.2.0'
         
     | 
| 
      
 7 
     | 
    
         
            +
            gem 'rails_compatibility', '~> 0.0.7'
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            gem 'carrierwave',  '~> 0.11.0'
         
     | 
| 
      
 10 
     | 
    
         
            +
            gem 'mimemagic', '< 0.4.3' # Used by carrierwave gem
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            gem 'globalize'
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            group :test do
         
     | 
| 
      
 15 
     | 
    
         
            +
              gem 'simplecov', '< 0.18'
         
     | 
| 
      
 16 
     | 
    
         
            +
            end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            gemspec path: '../'
         
     | 
| 
         @@ -1,13 +1,18 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            source 'https://rubygems.org'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            # Specify your gem's dependencies in pluck_all.gemspec
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
            gem 'sqlite3',      '~> 1.3.0'
         
     | 
| 
       6 
     | 
    
         
            -
            gem 'activerecord', '~> 5.0.0'
         
     | 
| 
       7 
     | 
    
         
            -
            gem ' 
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            source 'https://rubygems.org'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            # Specify your gem's dependencies in pluck_all.gemspec
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            gem 'sqlite3',      '~> 1.3.0'
         
     | 
| 
      
 6 
     | 
    
         
            +
            gem 'activerecord', '~> 5.0.0'
         
     | 
| 
      
 7 
     | 
    
         
            +
            gem 'rails_compatibility', '~> 0.0.7'
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            gem 'carrierwave',  '~> 0.11.0'
         
     | 
| 
      
 10 
     | 
    
         
            +
            gem 'mimemagic', '< 0.4.3' # Used by carrierwave gem
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            gem 'globalize'
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            group :test do
         
     | 
| 
      
 15 
     | 
    
         
            +
              gem 'simplecov', '< 0.18'
         
     | 
| 
      
 16 
     | 
    
         
            +
            end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            gemspec path: '../'
         
     | 
| 
         @@ -1,13 +1,18 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            source 'https://rubygems.org'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            # Specify your gem's dependencies in pluck_all.gemspec
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
            gem 'sqlite3',      '~> 1.3.0'
         
     | 
| 
       6 
     | 
    
         
            -
            gem 'activerecord', '~> 5.1.0'
         
     | 
| 
       7 
     | 
    
         
            -
            gem ' 
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            source 'https://rubygems.org'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            # Specify your gem's dependencies in pluck_all.gemspec
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            gem 'sqlite3',      '~> 1.3.0'
         
     | 
| 
      
 6 
     | 
    
         
            +
            gem 'activerecord', '~> 5.1.0'
         
     | 
| 
      
 7 
     | 
    
         
            +
            gem 'rails_compatibility', '~> 0.0.7'
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            gem 'carrierwave',  '~> 0.11.0'
         
     | 
| 
      
 10 
     | 
    
         
            +
            gem 'mimemagic', '< 0.4.3' # Used by carrierwave gem
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            gem 'globalize'
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            group :test do
         
     | 
| 
      
 15 
     | 
    
         
            +
              gem 'simplecov', '< 0.18'
         
     | 
| 
      
 16 
     | 
    
         
            +
            end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            gemspec path: '../'
         
     | 
| 
         @@ -1,13 +1,18 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            source 'https://rubygems.org'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            # Specify your gem's dependencies in pluck_all.gemspec
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
            gem 'sqlite3',      '~> 1.3.0'
         
     | 
| 
       6 
     | 
    
         
            -
            gem 'activerecord', '~> 5.2.0'
         
     | 
| 
       7 
     | 
    
         
            -
            gem ' 
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            source 'https://rubygems.org'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            # Specify your gem's dependencies in pluck_all.gemspec
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            gem 'sqlite3',      '~> 1.3.0'
         
     | 
| 
      
 6 
     | 
    
         
            +
            gem 'activerecord', '~> 5.2.0'
         
     | 
| 
      
 7 
     | 
    
         
            +
            gem 'rails_compatibility', '~> 0.0.7'
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            gem 'carrierwave',  '~> 0.11.0'
         
     | 
| 
      
 10 
     | 
    
         
            +
            gem 'mimemagic', '< 0.4.3' # Used by carrierwave gem
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            gem 'globalize'
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            group :test do
         
     | 
| 
      
 15 
     | 
    
         
            +
              gem 'simplecov', '< 0.18'
         
     | 
| 
      
 16 
     | 
    
         
            +
            end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            gemspec path: '../'
         
     | 
| 
         @@ -1,13 +1,18 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            source 'https://rubygems.org'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            # Specify your gem's dependencies in pluck_all.gemspec
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
            gem 'sqlite3',      '~> 1.4.1'
         
     | 
| 
       6 
     | 
    
         
            -
            gem 'activerecord', '~> 6.0.0'
         
     | 
| 
       7 
     | 
    
         
            -
            gem ' 
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            source 'https://rubygems.org'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            # Specify your gem's dependencies in pluck_all.gemspec
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            gem 'sqlite3',      '~> 1.4.1'
         
     | 
| 
      
 6 
     | 
    
         
            +
            gem 'activerecord', '~> 6.0.0'
         
     | 
| 
      
 7 
     | 
    
         
            +
            gem 'rails_compatibility', '~> 0.0.7'
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            gem 'carrierwave',  '~> 0.11.0'
         
     | 
| 
      
 10 
     | 
    
         
            +
            gem 'mimemagic', '< 0.4.3' # Used by carrierwave gem
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            gem 'globalize'
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            group :test do
         
     | 
| 
      
 15 
     | 
    
         
            +
              gem 'simplecov', '< 0.18'
         
     | 
| 
      
 16 
     | 
    
         
            +
            end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            gemspec path: '../'
         
     | 
| 
         @@ -1,13 +1,18 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            source 'https://rubygems.org'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            # Specify your gem's dependencies in pluck_all.gemspec
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
            gem 'sqlite3',      '~> 1.4.1'
         
     | 
| 
       6 
     | 
    
         
            -
            gem 'activerecord', '~> 6.1.0'
         
     | 
| 
       7 
     | 
    
         
            -
            gem ' 
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            source 'https://rubygems.org'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            # Specify your gem's dependencies in pluck_all.gemspec
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            gem 'sqlite3',      '~> 1.4.1'
         
     | 
| 
      
 6 
     | 
    
         
            +
            gem 'activerecord', '~> 6.1.0'
         
     | 
| 
      
 7 
     | 
    
         
            +
            gem 'rails_compatibility', '~> 0.0.7'
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            gem 'carrierwave',  '~> 0.11.0'
         
     | 
| 
      
 10 
     | 
    
         
            +
            gem 'mimemagic', '< 0.4.3' # Used by carrierwave gem
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            gem 'globalize'
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            group :test do
         
     | 
| 
      
 15 
     | 
    
         
            +
              gem 'simplecov', '< 0.18'
         
     | 
| 
      
 16 
     | 
    
         
            +
            end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            gemspec path: '../'
         
     | 
    
        data/gemfiles/mongoid_54.gemfile
    CHANGED
    
    | 
         @@ -1,11 +1,11 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            source 'https://rubygems.org'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            # Specify your gem's dependencies in pluck_all.gemspec
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
            gem 'mongoid', '~> 5.4.0'
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
            group :test do
         
     | 
| 
       8 
     | 
    
         
            -
              gem 'simplecov'
         
     | 
| 
       9 
     | 
    
         
            -
            end
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
            gemspec path: '../'
         
     | 
| 
      
 1 
     | 
    
         
            +
            source 'https://rubygems.org'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            # Specify your gem's dependencies in pluck_all.gemspec
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            gem 'mongoid', '~> 5.4.0'
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            group :test do
         
     | 
| 
      
 8 
     | 
    
         
            +
              gem 'simplecov', '< 0.18'
         
     | 
| 
      
 9 
     | 
    
         
            +
            end
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            gemspec path: '../'
         
     | 
    
        data/gemfiles/mongoid_64.gemfile
    CHANGED
    
    | 
         @@ -1,11 +1,11 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            source 'https://rubygems.org'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            # Specify your gem's dependencies in pluck_all.gemspec
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
            gem 'mongoid', '~> 6.4.0'
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
            group :test do
         
     | 
| 
       8 
     | 
    
         
            -
              gem 'simplecov'
         
     | 
| 
       9 
     | 
    
         
            -
            end
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
            gemspec path: '../'
         
     | 
| 
      
 1 
     | 
    
         
            +
            source 'https://rubygems.org'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            # Specify your gem's dependencies in pluck_all.gemspec
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            gem 'mongoid', '~> 6.4.0'
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            group :test do
         
     | 
| 
      
 8 
     | 
    
         
            +
              gem 'simplecov', '< 0.18'
         
     | 
| 
      
 9 
     | 
    
         
            +
            end
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            gemspec path: '../'
         
     | 
| 
         @@ -1,11 +1,11 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            source 'https://rubygems.org'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            # Specify your gem's dependencies in pluck_all.gemspec
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
            gem 'mongoid', '~> 7. 
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
            group :test do
         
     | 
| 
       8 
     | 
    
         
            -
              gem 'simplecov'
         
     | 
| 
       9 
     | 
    
         
            -
            end
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
            gemspec path: '../'
         
     | 
| 
      
 1 
     | 
    
         
            +
            source 'https://rubygems.org'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            # Specify your gem's dependencies in pluck_all.gemspec
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            gem 'mongoid', '~> 7.3.3'
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            group :test do
         
     | 
| 
      
 8 
     | 
    
         
            +
              gem 'simplecov', '< 0.18'
         
     | 
| 
      
 9 
     | 
    
         
            +
            end
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            gemspec path: '../'
         
     | 
    
        data/lib/pluck_all/hooks.rb
    CHANGED
    
    | 
         @@ -1,21 +1,21 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            module PluckAll
         
     | 
| 
       2 
     | 
    
         
            -
              class Hooks
         
     | 
| 
       3 
     | 
    
         
            -
                class << self
         
     | 
| 
       4 
     | 
    
         
            -
                  def init
         
     | 
| 
       5 
     | 
    
         
            -
                    require 'pluck_all/models/active_record_extension' if require_if_exists('active_record')
         
     | 
| 
       6 
     | 
    
         
            -
                    require 'pluck_all/models/mongoid_extension' if require_if_exists('mongoid')
         
     | 
| 
       7 
     | 
    
         
            -
                  end
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
                  private
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
                  def require_if_exists(path)
         
     | 
| 
       12 
     | 
    
         
            -
                    require path
         
     | 
| 
       13 
     | 
    
         
            -
                    return true
         
     | 
| 
       14 
     | 
    
         
            -
                  rescue LoadError, Gem::LoadError
         
     | 
| 
       15 
     | 
    
         
            -
                    return false
         
     | 
| 
       16 
     | 
    
         
            -
                  end
         
     | 
| 
       17 
     | 
    
         
            -
                end
         
     | 
| 
       18 
     | 
    
         
            -
              end
         
     | 
| 
       19 
     | 
    
         
            -
            end
         
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
            PluckAll::Hooks.init
         
     | 
| 
      
 1 
     | 
    
         
            +
            module PluckAll
         
     | 
| 
      
 2 
     | 
    
         
            +
              class Hooks
         
     | 
| 
      
 3 
     | 
    
         
            +
                class << self
         
     | 
| 
      
 4 
     | 
    
         
            +
                  def init
         
     | 
| 
      
 5 
     | 
    
         
            +
                    require 'pluck_all/models/active_record_extension' if require_if_exists('active_record')
         
     | 
| 
      
 6 
     | 
    
         
            +
                    require 'pluck_all/models/mongoid_extension' if require_if_exists('mongoid')
         
     | 
| 
      
 7 
     | 
    
         
            +
                  end
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                  private
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                  def require_if_exists(path)
         
     | 
| 
      
 12 
     | 
    
         
            +
                    require path
         
     | 
| 
      
 13 
     | 
    
         
            +
                    return true
         
     | 
| 
      
 14 
     | 
    
         
            +
                  rescue LoadError, Gem::LoadError
         
     | 
| 
      
 15 
     | 
    
         
            +
                    return false
         
     | 
| 
      
 16 
     | 
    
         
            +
                  end
         
     | 
| 
      
 17 
     | 
    
         
            +
                end
         
     | 
| 
      
 18 
     | 
    
         
            +
              end
         
     | 
| 
      
 19 
     | 
    
         
            +
            end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
            PluckAll::Hooks.init
         
     | 
| 
         @@ -1,131 +1,138 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require 'rails_compatibility/attribute_types'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
                 
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
               
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
                 
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
                  column_names 
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
                 
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
                     
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
                     
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
     | 
    
         
            -
                 
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
       49 
     | 
    
         
            -
                     
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
       52 
     | 
    
         
            -
                   
     | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
       54 
     | 
    
         
            -
             
     | 
| 
       55 
     | 
    
         
            -
             
     | 
| 
       56 
     | 
    
         
            -
             
     | 
| 
       57 
     | 
    
         
            -
             
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
       60 
     | 
    
         
            -
                   
     | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
       63 
     | 
    
         
            -
             
     | 
| 
       64 
     | 
    
         
            -
             
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
             
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
       73 
     | 
    
         
            -
             
     | 
| 
       74 
     | 
    
         
            -
             
     | 
| 
       75 
     | 
    
         
            -
             
     | 
| 
       76 
     | 
    
         
            -
             
     | 
| 
       77 
     | 
    
         
            -
             
     | 
| 
       78 
     | 
    
         
            -
             
     | 
| 
       79 
     | 
    
         
            -
             
     | 
| 
       80 
     | 
    
         
            -
             
     | 
| 
       81 
     | 
    
         
            -
             
     | 
| 
       82 
     | 
    
         
            -
                 
     | 
| 
       83 
     | 
    
         
            -
             
     | 
| 
       84 
     | 
    
         
            -
             
     | 
| 
       85 
     | 
    
         
            -
             
     | 
| 
       86 
     | 
    
         
            -
             
     | 
| 
       87 
     | 
    
         
            -
             
     | 
| 
       88 
     | 
    
         
            -
             
     | 
| 
       89 
     | 
    
         
            -
             
     | 
| 
       90 
     | 
    
         
            -
             
     | 
| 
       91 
     | 
    
         
            -
             
     | 
| 
       92 
     | 
    
         
            -
             
     | 
| 
       93 
     | 
    
         
            -
             
     | 
| 
       94 
     | 
    
         
            -
             
     | 
| 
       95 
     | 
    
         
            -
             
     | 
| 
       96 
     | 
    
         
            -
             
     | 
| 
       97 
     | 
    
         
            -
             
     | 
| 
       98 
     | 
    
         
            -
             
     | 
| 
       99 
     | 
    
         
            -
             
     | 
| 
       100 
     | 
    
         
            -
             
     | 
| 
       101 
     | 
    
         
            -
             
     | 
| 
       102 
     | 
    
         
            -
                 
     | 
| 
       103 
     | 
    
         
            -
             
     | 
| 
       104 
     | 
    
         
            -
             
     | 
| 
       105 
     | 
    
         
            -
             
     | 
| 
       106 
     | 
    
         
            -
             
     | 
| 
       107 
     | 
    
         
            -
             
     | 
| 
       108 
     | 
    
         
            -
               
     | 
| 
       109 
     | 
    
         
            -
                 
     | 
| 
       110 
     | 
    
         
            -
             
     | 
| 
       111 
     | 
    
         
            -
             
     | 
| 
       112 
     | 
    
         
            -
             
     | 
| 
       113 
     | 
    
         
            -
             
     | 
| 
       114 
     | 
    
         
            -
             
     | 
| 
       115 
     | 
    
         
            -
             
     | 
| 
       116 
     | 
    
         
            -
             
     | 
| 
       117 
     | 
    
         
            -
             
     | 
| 
       118 
     | 
    
         
            -
             
     | 
| 
       119 
     | 
    
         
            -
             
     | 
| 
       120 
     | 
    
         
            -
             
     | 
| 
       121 
     | 
    
         
            -
             
     | 
| 
       122 
     | 
    
         
            -
             
     | 
| 
       123 
     | 
    
         
            -
             
     | 
| 
       124 
     | 
    
         
            -
             
     | 
| 
       125 
     | 
    
         
            -
             
     | 
| 
       126 
     | 
    
         
            -
             
     | 
| 
       127 
     | 
    
         
            -
             
     | 
| 
       128 
     | 
    
         
            -
             
     | 
| 
       129 
     | 
    
         
            -
             
     | 
| 
       130 
     | 
    
         
            -
             
     | 
| 
       131 
     | 
    
         
            -
            end
         
     | 
| 
      
 1 
     | 
    
         
            +
            require 'rails_compatibility/attribute_types'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'rails_compatibility/has_include'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'rails_compatibility/apply_join_dependency'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require_relative 'patches/deserialize'
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            class ActiveRecord::Relation
         
     | 
| 
      
 7 
     | 
    
         
            +
              def cast_need_columns(column_names, _klass = nil)
         
     | 
| 
      
 8 
     | 
    
         
            +
                @pluck_all_cast_need_columns = column_names.map(&:to_s)
         
     | 
| 
      
 9 
     | 
    
         
            +
                @pluck_all_cast_klass = _klass
         
     | 
| 
      
 10 
     | 
    
         
            +
                return self
         
     | 
| 
      
 11 
     | 
    
         
            +
              end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
              def select_all(column_names)
         
     | 
| 
      
 14 
     | 
    
         
            +
                relation = clone
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                # See: https://github.com/globalize/globalize/pull/707
         
     | 
| 
      
 17 
     | 
    
         
            +
                if relation.klass.method_defined?(:translated_attribute_names) && (parsed = parse_translated_columns(column_names))
         
     | 
| 
      
 18 
     | 
    
         
            +
                  relation = relation.join_translations
         
     | 
| 
      
 19 
     | 
    
         
            +
                  column_names = parsed
         
     | 
| 
      
 20 
     | 
    
         
            +
                end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                relation.select_values = [].freeze # cannot use `unscope(:select)` in Rails 3
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                sql = relation.select(column_names.map(&to_sql_column_name)).to_sql
         
     | 
| 
      
 25 
     | 
    
         
            +
                return klass.connection.select_all(sql)
         
     | 
| 
      
 26 
     | 
    
         
            +
              end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
              if Gem::Version.new(ActiveRecord::VERSION::STRING) < Gem::Version.new('4.0.0')
         
     | 
| 
      
 29 
     | 
    
         
            +
                def pluck_all(*column_names, cast_uploader_url: true)
         
     | 
| 
      
 30 
     | 
    
         
            +
                  result = select_all(column_names)
         
     | 
| 
      
 31 
     | 
    
         
            +
                  result.map! do |attributes| # This map! behaves different to array#map!
         
     | 
| 
      
 32 
     | 
    
         
            +
                    initialized_attributes = klass.initialize_attributes(attributes)
         
     | 
| 
      
 33 
     | 
    
         
            +
                    attributes.each do |key, _attribute|
         
     | 
| 
      
 34 
     | 
    
         
            +
                      attributes[key] = klass.type_cast_attribute(key, initialized_attributes) # TODO: 現在AS過後的type cast會有一點問題
         
     | 
| 
      
 35 
     | 
    
         
            +
                    end
         
     | 
| 
      
 36 
     | 
    
         
            +
                    cast_carrier_wave_uploader_url(attributes) if cast_uploader_url
         
     | 
| 
      
 37 
     | 
    
         
            +
                    next attributes
         
     | 
| 
      
 38 
     | 
    
         
            +
                  end
         
     | 
| 
      
 39 
     | 
    
         
            +
                end
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
                private
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                def to_sql_column_name
         
     | 
| 
      
 44 
     | 
    
         
            +
                  proc do |column_name|
         
     | 
| 
      
 45 
     | 
    
         
            +
                    if column_name.is_a?(Arel::Attributes::Attribute)
         
     | 
| 
      
 46 
     | 
    
         
            +
                      "#{column_name.relation.name}.#{column_name.name}"
         
     | 
| 
      
 47 
     | 
    
         
            +
                    elsif column_name.is_a?(Symbol) && column_names.include?(column_name.to_s)
         
     | 
| 
      
 48 
     | 
    
         
            +
                      "#{connection.quote_table_name(table_name)}.#{connection.quote_column_name(column_name)}"
         
     | 
| 
      
 49 
     | 
    
         
            +
                    else
         
     | 
| 
      
 50 
     | 
    
         
            +
                      column_name.to_s
         
     | 
| 
      
 51 
     | 
    
         
            +
                    end
         
     | 
| 
      
 52 
     | 
    
         
            +
                  end
         
     | 
| 
      
 53 
     | 
    
         
            +
                end
         
     | 
| 
      
 54 
     | 
    
         
            +
              else
         
     | 
| 
      
 55 
     | 
    
         
            +
                def pluck_all(*column_names, cast_uploader_url: true)
         
     | 
| 
      
 56 
     | 
    
         
            +
                  has_include = RailsCompatibility.has_include?(self, column_names.first)
         
     | 
| 
      
 57 
     | 
    
         
            +
                  return RailsCompatibility.apply_join_dependency(self).pluck_all(*column_names) if has_include
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
                  result = select_all(column_names)
         
     | 
| 
      
 60 
     | 
    
         
            +
                  attribute_types = RailsCompatibility.attribute_types(klass)
         
     | 
| 
      
 61 
     | 
    
         
            +
                  result.map do |attributes| # This map behaves different to array#map
         
     | 
| 
      
 62 
     | 
    
         
            +
                    attributes.each do |key, attribute|
         
     | 
| 
      
 63 
     | 
    
         
            +
                      attributes[key] = result.send(:column_type, key, attribute_types).deserialize(attribute) # TODO: 現在AS過後的type cast會有一點問題,但似乎原生的pluck也有此問題
         
     | 
| 
      
 64 
     | 
    
         
            +
                    end
         
     | 
| 
      
 65 
     | 
    
         
            +
                    cast_carrier_wave_uploader_url(attributes) if cast_uploader_url
         
     | 
| 
      
 66 
     | 
    
         
            +
                    next attributes
         
     | 
| 
      
 67 
     | 
    
         
            +
                  end
         
     | 
| 
      
 68 
     | 
    
         
            +
                end
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
                private
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
                def to_sql_column_name
         
     | 
| 
      
 73 
     | 
    
         
            +
                  proc do |column_name|
         
     | 
| 
      
 74 
     | 
    
         
            +
                    if column_name.is_a?(Arel::Attributes::Attribute)
         
     | 
| 
      
 75 
     | 
    
         
            +
                      "#{column_name.relation.name}.#{column_name.name}"
         
     | 
| 
      
 76 
     | 
    
         
            +
                    elsif column_name.is_a?(Symbol) && attribute_alias?(column_name)
         
     | 
| 
      
 77 
     | 
    
         
            +
                      attribute_alias(column_name)
         
     | 
| 
      
 78 
     | 
    
         
            +
                    else
         
     | 
| 
      
 79 
     | 
    
         
            +
                      column_name.to_s
         
     | 
| 
      
 80 
     | 
    
         
            +
                    end
         
     | 
| 
      
 81 
     | 
    
         
            +
                  end
         
     | 
| 
      
 82 
     | 
    
         
            +
                end
         
     | 
| 
      
 83 
     | 
    
         
            +
              end
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
              # ----------------------------------------------------------------
         
     | 
| 
      
 86 
     | 
    
         
            +
              # ● Support casting CarrierWave url
         
     | 
| 
      
 87 
     | 
    
         
            +
              # ----------------------------------------------------------------
         
     | 
| 
      
 88 
     | 
    
         
            +
              def cast_carrier_wave_uploader_url(attributes)
         
     | 
| 
      
 89 
     | 
    
         
            +
                if defined?(CarrierWave) && klass.respond_to?(:uploaders)
         
     | 
| 
      
 90 
     | 
    
         
            +
                  @pluck_all_cast_need_columns ||= nil
         
     | 
| 
      
 91 
     | 
    
         
            +
                  @pluck_all_cast_klass ||= klass
         
     | 
| 
      
 92 
     | 
    
         
            +
                  @pluck_all_uploaders ||= @pluck_all_cast_klass.uploaders.select{|key, _uploader| attributes.key?(key.to_s) }
         
     | 
| 
      
 93 
     | 
    
         
            +
                  @pluck_all_uploaders.each do |key, _uploader|
         
     | 
| 
      
 94 
     | 
    
         
            +
                    {}.tap do |hash|
         
     | 
| 
      
 95 
     | 
    
         
            +
                      @pluck_all_cast_need_columns.each{|k| hash[k] = attributes[k] } if @pluck_all_cast_need_columns
         
     | 
| 
      
 96 
     | 
    
         
            +
                      obj = @pluck_all_cast_klass.instantiate(hash)
         
     | 
| 
      
 97 
     | 
    
         
            +
                      obj[key] = attributes[key_s = key.to_s]
         
     | 
| 
      
 98 
     | 
    
         
            +
                      # https://github.com/carrierwaveuploader/carrierwave/blob/87c37b706c560de6d01816f9ebaa15ce1c51ed58/lib/carrierwave/mount.rb#L142
         
     | 
| 
      
 99 
     | 
    
         
            +
                      attributes[key_s] = obj.send(key)
         
     | 
| 
      
 100 
     | 
    
         
            +
                    end
         
     | 
| 
      
 101 
     | 
    
         
            +
                  end
         
     | 
| 
      
 102 
     | 
    
         
            +
                end
         
     | 
| 
      
 103 
     | 
    
         
            +
                return attributes
         
     | 
| 
      
 104 
     | 
    
         
            +
              end
         
     | 
| 
      
 105 
     | 
    
         
            +
            end
         
     | 
| 
      
 106 
     | 
    
         
            +
             
     | 
| 
      
 107 
     | 
    
         
            +
            class ActiveRecord::Relation
         
     | 
| 
      
 108 
     | 
    
         
            +
              if Gem::Version.new(ActiveRecord::VERSION::STRING) < Gem::Version.new('4.0.2')
         
     | 
| 
      
 109 
     | 
    
         
            +
                def pluck_array(*args)
         
     | 
| 
      
 110 
     | 
    
         
            +
                  return pluck_all(*args, cast_uploader_url: false).map do |hash|
         
     | 
| 
      
 111 
     | 
    
         
            +
                    result = hash.values # P.S. 這裡是相信ruby 1.9以後,hash.values的順序跟insert的順序一樣。
         
     | 
| 
      
 112 
     | 
    
         
            +
                    next (args.one? ? result.first : result)
         
     | 
| 
      
 113 
     | 
    
         
            +
                  end
         
     | 
| 
      
 114 
     | 
    
         
            +
                end
         
     | 
| 
      
 115 
     | 
    
         
            +
              else
         
     | 
| 
      
 116 
     | 
    
         
            +
                alias pluck_array pluck if not method_defined?(:pluck_array)
         
     | 
| 
      
 117 
     | 
    
         
            +
              end
         
     | 
| 
      
 118 
     | 
    
         
            +
            end
         
     | 
| 
      
 119 
     | 
    
         
            +
             
     | 
| 
      
 120 
     | 
    
         
            +
            class << ActiveRecord::Base
         
     | 
| 
      
 121 
     | 
    
         
            +
              def cast_need_columns(*args)
         
     | 
| 
      
 122 
     | 
    
         
            +
                where(nil).cast_need_columns(*args)
         
     | 
| 
      
 123 
     | 
    
         
            +
              end
         
     | 
| 
      
 124 
     | 
    
         
            +
             
     | 
| 
      
 125 
     | 
    
         
            +
              def pluck_all(*args)
         
     | 
| 
      
 126 
     | 
    
         
            +
                where(nil).pluck_all(*args)
         
     | 
| 
      
 127 
     | 
    
         
            +
              end
         
     | 
| 
      
 128 
     | 
    
         
            +
             
     | 
| 
      
 129 
     | 
    
         
            +
              def pluck_array(*args)
         
     | 
| 
      
 130 
     | 
    
         
            +
                where(nil).pluck_array(*args)
         
     | 
| 
      
 131 
     | 
    
         
            +
              end
         
     | 
| 
      
 132 
     | 
    
         
            +
            end
         
     | 
| 
      
 133 
     | 
    
         
            +
             
     | 
| 
      
 134 
     | 
    
         
            +
            module ActiveRecord::NullRelation
         
     | 
| 
      
 135 
     | 
    
         
            +
              def pluck_all(*_args)
         
     | 
| 
      
 136 
     | 
    
         
            +
                []
         
     | 
| 
      
 137 
     | 
    
         
            +
              end
         
     | 
| 
      
 138 
     | 
    
         
            +
            end
         
     |