simple_record 1.2.0 → 1.2.1
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/simple_record.rb +5 -1
- data/test/test_base.rb +1 -0
- data/test/test_pagination.rb +4 -1
- metadata +3 -3
data/lib/simple_record.rb
CHANGED
@@ -52,6 +52,10 @@ module SimpleRecord
|
|
52
52
|
@@logging = false
|
53
53
|
end
|
54
54
|
|
55
|
+
def self.logging?
|
56
|
+
@@logging
|
57
|
+
end
|
58
|
+
|
55
59
|
def self.stats
|
56
60
|
@@stats
|
57
61
|
end
|
@@ -717,7 +721,7 @@ module SimpleRecord
|
|
717
721
|
# to start at a specific row. So it will iterate from the first record and pull out the specific pages.
|
718
722
|
def self.paginate(options={})
|
719
723
|
# options = args.pop
|
720
|
-
puts 'paginate options=' + options.inspect if
|
724
|
+
puts 'paginate options=' + options.inspect if SimpleRecord.logging?
|
721
725
|
page = options[:page] || 1
|
722
726
|
per_page = options[:per_page] || self.per_page || 50
|
723
727
|
total = options[:total_entries]
|
data/test/test_base.rb
CHANGED
data/test/test_pagination.rb
CHANGED
@@ -16,11 +16,14 @@ class TestPagination < TestBase
|
|
16
16
|
def test_paginate
|
17
17
|
create_my_models(20)
|
18
18
|
|
19
|
+
i = 20
|
19
20
|
(1..3).each do |page|
|
20
|
-
models = MyModel.paginate :page=>page, :per_page=>5, :order=>"
|
21
|
+
models = MyModel.paginate :page=>page, :per_page=>5, :order=>"created desc"
|
21
22
|
assert models.size == 5
|
22
23
|
models.each do |m|
|
24
|
+
i -= 1
|
23
25
|
puts m.name
|
26
|
+
assert m.age == i
|
24
27
|
end
|
25
28
|
end
|
26
29
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 1.2.
|
8
|
+
- 1
|
9
|
+
version: 1.2.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Travis Reeder
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-05-
|
19
|
+
date: 2010-05-08 00:00:00 -07:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|