magic_grid 0.12.2 → 0.12.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.
- data/lib/magic_grid/collection.rb +19 -1
 - data/lib/magic_grid/version.rb +1 -1
 - metadata +6 -6
 
| 
         @@ -207,8 +207,15 @@ module MagicGrid 
     | 
|
| 
       207 
207 
     | 
    
         
             
                def perform_pagination(collection)
         
     | 
| 
       208 
208 
     | 
    
         
             
                  return collection unless @per_page
         
     | 
| 
       209 
209 
     | 
    
         | 
| 
      
 210 
     | 
    
         
            +
                  total_entries = count(collection)
         
     | 
| 
      
 211 
     | 
    
         
            +
                  @current_page = bound_current_page(@current_page,
         
     | 
| 
      
 212 
     | 
    
         
            +
                                                     @per_page,
         
     | 
| 
      
 213 
     | 
    
         
            +
                                                     total_entries)
         
     | 
| 
      
 214 
     | 
    
         
            +
             
     | 
| 
       210 
215 
     | 
    
         
             
                  if collection.respond_to? :paginate
         
     | 
| 
       211 
     | 
    
         
            -
                    collection.paginate(page: @current_page, 
     | 
| 
      
 216 
     | 
    
         
            +
                    collection.paginate(page: @current_page,
         
     | 
| 
      
 217 
     | 
    
         
            +
                                        per_page: @per_page,
         
     | 
| 
      
 218 
     | 
    
         
            +
                                        total_entries: total_entries)
         
     | 
| 
       212 
219 
     | 
    
         
             
                  elsif collection.respond_to? :page
         
     | 
| 
       213 
220 
     | 
    
         
             
                    collection.page(@current_page).per(@per_page)
         
     | 
| 
       214 
221 
     | 
    
         
             
                  elsif collection.is_a?(Array) and Module.const_defined?(:Kaminari)
         
     | 
| 
         @@ -249,5 +256,16 @@ module MagicGrid 
     | 
|
| 
       249 
256 
     | 
    
         
             
                  @reduced_collection ||= apply_all_operations(@collection)
         
     | 
| 
       250 
257 
     | 
    
         
             
                end
         
     | 
| 
       251 
258 
     | 
    
         | 
| 
      
 259 
     | 
    
         
            +
                private
         
     | 
| 
      
 260 
     | 
    
         
            +
             
     | 
| 
      
 261 
     | 
    
         
            +
                def bound_current_page(page, per_page, total_entries)
         
     | 
| 
      
 262 
     | 
    
         
            +
                  pages = total_entries / per_page
         
     | 
| 
      
 263 
     | 
    
         
            +
                  pages = 1 if pages == 0
         
     | 
| 
      
 264 
     | 
    
         
            +
                  if page > pages
         
     | 
| 
      
 265 
     | 
    
         
            +
                    pages
         
     | 
| 
      
 266 
     | 
    
         
            +
                  else
         
     | 
| 
      
 267 
     | 
    
         
            +
                    page
         
     | 
| 
      
 268 
     | 
    
         
            +
                  end
         
     | 
| 
      
 269 
     | 
    
         
            +
                end
         
     | 
| 
       252 
270 
     | 
    
         
             
              end
         
     | 
| 
       253 
271 
     | 
    
         
             
            end
         
     | 
    
        data/lib/magic_grid/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: magic_grid
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.12. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.12.3
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: 
         
     | 
| 
       6 
6 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       7 
7 
     | 
    
         
             
            authors:
         
     | 
| 
         @@ -9,7 +9,7 @@ authors: 
     | 
|
| 
       9 
9 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       10 
10 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       11 
11 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       12 
     | 
    
         
            -
            date: 2012-11- 
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2012-11-30 00:00:00.000000000 Z
         
     | 
| 
       13 
13 
     | 
    
         
             
            dependencies:
         
     | 
| 
       14 
14 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       15 
15 
     | 
    
         
             
              name: rails
         
     | 
| 
         @@ -48,7 +48,7 @@ dependencies: 
     | 
|
| 
       48 
48 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       49 
49 
     | 
    
         
             
                none: false
         
     | 
| 
       50 
50 
     | 
    
         
             
                requirements:
         
     | 
| 
       51 
     | 
    
         
            -
                - -  
     | 
| 
      
 51 
     | 
    
         
            +
                - - ! '>='
         
     | 
| 
       52 
52 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       53 
53 
     | 
    
         
             
                    version: 0.9.2
         
     | 
| 
       54 
54 
     | 
    
         
             
              type: :development
         
     | 
| 
         @@ -56,7 +56,7 @@ dependencies: 
     | 
|
| 
       56 
56 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       57 
57 
     | 
    
         
             
                none: false
         
     | 
| 
       58 
58 
     | 
    
         
             
                requirements:
         
     | 
| 
       59 
     | 
    
         
            -
                - -  
     | 
| 
      
 59 
     | 
    
         
            +
                - - ! '>='
         
     | 
| 
       60 
60 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       61 
61 
     | 
    
         
             
                    version: 0.9.2
         
     | 
| 
       62 
62 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
         @@ -215,7 +215,7 @@ required_ruby_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       215 
215 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       216 
216 
     | 
    
         
             
                  segments:
         
     | 
| 
       217 
217 
     | 
    
         
             
                  - 0
         
     | 
| 
       218 
     | 
    
         
            -
                  hash:  
     | 
| 
      
 218 
     | 
    
         
            +
                  hash: 1658296312752844098
         
     | 
| 
       219 
219 
     | 
    
         
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
       220 
220 
     | 
    
         
             
              none: false
         
     | 
| 
       221 
221 
     | 
    
         
             
              requirements:
         
     | 
| 
         @@ -224,7 +224,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       224 
224 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       225 
225 
     | 
    
         
             
                  segments:
         
     | 
| 
       226 
226 
     | 
    
         
             
                  - 0
         
     | 
| 
       227 
     | 
    
         
            -
                  hash:  
     | 
| 
      
 227 
     | 
    
         
            +
                  hash: 1658296312752844098
         
     | 
| 
       228 
228 
     | 
    
         
             
            requirements: []
         
     | 
| 
       229 
229 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       230 
230 
     | 
    
         
             
            rubygems_version: 1.8.23
         
     |