directiverecord 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NGU4Njg2NzU3OTk2NzUyYzlkYWVhMTQ3OTYwODQ1YWVjNmMyNjRiZQ==
4
+ YjVjYzQ4YmJiZjVmMmFhOGVlN2JjMzdlNWUwZTQxODNjMDRlODNlOA==
5
5
  data.tar.gz: !binary |-
6
- NWE2MjQ5NThkZTZhMmJlZmZiODZiMzdkMGZlNjk4YWIzODcyMzBhZQ==
6
+ YjRhYzE3ZThhYjFkNDI4MjQ2Y2FmNDY1ZTQ1ZDgwMjViZWFhYjYwNg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- N2ZlOGE0Yjc2NDU4YzViOWZmZGRlMzAxOWM1YTY0OWQ4MmU3MjFiODQ4MTlm
10
- N2RlYjFhNWE4NzZhYjNlODMxYmFkYTQ5NmQyNDJjMjlkNzE3NmMyZmQ0Njc3
11
- YjAxYzhlNTUyY2UwOTQ0NmE3MGNiMTk1ZTI2ODg1ZWI2ZjRhMjQ=
9
+ ZTUyZTliMzI1Zjg1MzA1ZjA3N2Q4NTA0ODZiZjU3ZTJlMGNmZjQ5YmM3NTMz
10
+ MzUxZDlmZmFlODcyMWM1NjgxODcxYmExYTc5MzE5MjQwZDVjMzUxMTg5YTUy
11
+ ZTMwZmQ4YmUzMTg2YzYyOWM1NGJjYTQ4M2RiNGVhYjQ4ZTlmNDk=
12
12
  data.tar.gz: !binary |-
13
- MDdkZWVmZDExZmMwMzY1ZTRkZjdmODI2OWIwY2M4NTc4OTMwZTk1MWZmNmUz
14
- ZGZkYjQwNjY3Zjk0ZTQ1NjU0MDExYWU5MzI0Y2E1N2I4NDdhYjk1NTJiYjQ2
15
- YTM2YTAzNjFmMzQ2Yzc4NmIzODcwZDllZDg0OWM1ODc5NjhlZDc=
13
+ NmYxMTAwYWEwY2U3NzI2ZmJmODhjYzNiNTZkMDk4YzFkOTVhODFlYzEyNWU1
14
+ N2RhOTlhZDJlNDAzNzhlNmJkMjUyNjVkMWYyNTRmNjZhOThkYjEwNTJmYWFi
15
+ ZThlZmQ2M2JiYzM3NTUyYmUzNDI4MmQ5OTE4MjRkNGI5Mjc1MDA=
data/CHANGELOG.rdoc CHANGED
@@ -1,5 +1,9 @@
1
1
  = DirectiveRecord CHANGELOG
2
2
 
3
+ == Version 0.1.9 (March 4, 2015)
4
+
5
+ * Overridden ActiveRecord::Relation#size to hook in DirectiveRecord query mechanism
6
+
3
7
  == Version 0.1.8 (February 25, 2015)
4
8
 
5
9
  * Corrected auto-applying MAX(..) aggregate function within BigQuery SELECT statements
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.8
1
+ 0.1.9
@@ -13,5 +13,11 @@ module ActiveRecord
13
13
  klass.qry qry_options(*args)
14
14
  end
15
15
 
16
+ alias :original_size :size
17
+
18
+ def size
19
+ loaded? ? original_size : qry("COUNT(*)")[0][0]
20
+ end
21
+
16
22
  end
17
23
  end
@@ -1,7 +1,7 @@
1
1
  module DirectiveRecord
2
2
  MAJOR = 0
3
3
  MINOR = 1
4
- TINY = 8
4
+ TINY = 9
5
5
 
6
6
  VERSION = [MAJOR, MINOR, TINY].join(".")
7
7
  end
@@ -34,6 +34,23 @@ module Unit
34
34
  assert_equal %w(NYC), @relation.qry("city")
35
35
  end
36
36
  end
37
+
38
+ describe "#size" do
39
+ describe "when loaded" do
40
+ it "invokes the original size method" do
41
+ @relation.expects(:loaded?).returns(true)
42
+ @relation.expects(:original_size)
43
+ @relation.size
44
+ end
45
+ end
46
+ describe "when not loaded" do
47
+ it "uses qry to count the records" do
48
+ @relation.expects(:loaded?).returns(false)
49
+ @relation.expects(:qry).with("COUNT(*)").returns([[1982]])
50
+ assert_equal 1982, @relation.size
51
+ end
52
+ end
53
+ end
37
54
  end
38
55
 
39
56
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: directiverecord
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Engel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-25 00:00:00.000000000 Z
11
+ date: 2015-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord