Module: Kaminari::ObjectJSONMapper::ObjectJSONMapperCriteriaMethods
- Defined in:
- lib/object_json_mapper/extensions/kaminari.rb
Instance Method Summary collapse
- #current_page ⇒ Object
- #limit_value ⇒ Object
- #max_pages ⇒ Object
- #offset_value ⇒ Object
- #total_count ⇒ Object
- #total_pages ⇒ Object
Instance Method Details
#current_page ⇒ Object
33 34 35 36 |
# File 'lib/object_json_mapper/extensions/kaminari.rb', line 33 def current_page page = conditions[:page].to_i page > 0 ? page : 1 end |
#limit_value ⇒ Object
14 15 16 17 |
# File 'lib/object_json_mapper/extensions/kaminari.rb', line 14 def limit_value collection unless @limit_value @limit_value end |
#max_pages ⇒ Object
38 39 40 |
# File 'lib/object_json_mapper/extensions/kaminari.rb', line 38 def max_pages total_count / offset_value end |
#offset_value ⇒ Object
29 30 31 |
# File 'lib/object_json_mapper/extensions/kaminari.rb', line 29 def offset_value limit_value * current_page end |
#total_count ⇒ Object
19 20 21 22 |
# File 'lib/object_json_mapper/extensions/kaminari.rb', line 19 def total_count collection unless @total_count @total_count end |
#total_pages ⇒ Object
24 25 26 27 |
# File 'lib/object_json_mapper/extensions/kaminari.rb', line 24 def total_pages return 1 if limit_value.zero? (total_count.to_f / limit_value).ceil end |