directiverecord 0.1.9 → 0.1.10

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YjVjYzQ4YmJiZjVmMmFhOGVlN2JjMzdlNWUwZTQxODNjMDRlODNlOA==
4
+ NDNjNWU1NTk0ZmM0MTViZDgyZDAxMmJkNmI5OWYwZTQ4MGUzNmIzZQ==
5
5
  data.tar.gz: !binary |-
6
- YjRhYzE3ZThhYjFkNDI4MjQ2Y2FmNDY1ZTQ1ZDgwMjViZWFhYjYwNg==
6
+ MDEwNjA5YmQ2ZTRkM2Q2ZjFjZDY3MGViYTE0ZTJmN2YyZDQyMzQxOA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZTUyZTliMzI1Zjg1MzA1ZjA3N2Q4NTA0ODZiZjU3ZTJlMGNmZjQ5YmM3NTMz
10
- MzUxZDlmZmFlODcyMWM1NjgxODcxYmExYTc5MzE5MjQwZDVjMzUxMTg5YTUy
11
- ZTMwZmQ4YmUzMTg2YzYyOWM1NGJjYTQ4M2RiNGVhYjQ4ZTlmNDk=
9
+ ZmE4ZjdjNzVhNzRhYjk4NjI5NjkzMzY0ZDQyZDE3OTAxMTM2YWVjODNmZDlm
10
+ NGRmN2RkMzBkMGFmZDUyMDc5ODk1YjlhNjUxNDU3NGU2NDE3YTFhNzkzZWRl
11
+ ZTkzNmE3YTJhODA0ZTIyMjBhZDY2OGI3ZmIxY2ZiZWYwOTUxY2I=
12
12
  data.tar.gz: !binary |-
13
- NmYxMTAwYWEwY2U3NzI2ZmJmODhjYzNiNTZkMDk4YzFkOTVhODFlYzEyNWU1
14
- N2RhOTlhZDJlNDAzNzhlNmJkMjUyNjVkMWYyNTRmNjZhOThkYjEwNTJmYWFi
15
- ZThlZmQ2M2JiYzM3NTUyYmUzNDI4MmQ5OTE4MjRkNGI5Mjc1MDA=
13
+ NmNlNjkyZDE1NjRhZjI2NmZlNDk3MmM0M2IzYjJiZDUxY2ZhMjg3MWM0Mjc2
14
+ NjU4NjM0M2YwZWY3ZTY0MGZlZWRjN2VkN2M0ZjU0ZDBjOWVjYjdlY2NlMTE1
15
+ MDJjMWVmMmYwZDk1NTE0YTE4MDAwM2M0MDk3OTNiYzEyMDQ5MDc=
@@ -1,5 +1,10 @@
1
1
  = DirectiveRecord CHANGELOG
2
2
 
3
+ == Version 0.1.10 (March 5, 2015)
4
+
5
+ * Overridden ActiveRecord::Relation#count(:all) to hook in DirectiveRecord query mechanism
6
+ * Dropped ActiveRecord::Relation#size override
7
+
3
8
  == Version 0.1.9 (March 4, 2015)
4
9
 
5
10
  * Overridden ActiveRecord::Relation#size to hook in DirectiveRecord query mechanism
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.9
1
+ 0.1.10
@@ -13,10 +13,14 @@ module ActiveRecord
13
13
  klass.qry qry_options(*args)
14
14
  end
15
15
 
16
- alias :original_size :size
16
+ alias :original_count :count
17
17
 
18
- def size
19
- loaded? ? original_size : qry("COUNT(*)")[0][0]
18
+ def count(column_name = nil, options = {})
19
+ if !loaded? && (column_name == :all) && (options == {})
20
+ qry("COUNT(*)")[0][0]
21
+ else
22
+ original_count column_name, options
23
+ end
20
24
  end
21
25
 
22
26
  end
@@ -1,7 +1,7 @@
1
1
  module DirectiveRecord
2
2
  MAJOR = 0
3
3
  MINOR = 1
4
- TINY = 9
4
+ TINY = 10
5
5
 
6
6
  VERSION = [MAJOR, MINOR, TINY].join(".")
7
7
  end
@@ -35,19 +35,32 @@ module Unit
35
35
  end
36
36
  end
37
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
38
+ describe "#count" do
39
+ describe "when only passing :all" do
40
+ describe "when loaded" do
41
+ it "invokes the original count method" do
42
+ @relation.expects(:loaded?).returns(true)
43
+ @relation.expects(:original_count)
44
+ @relation.count(:all)
45
+ end
46
+ end
47
+ describe "when not loaded" do
48
+ it "uses qry to count the records" do
49
+ @relation.expects(:loaded?).returns(false)
50
+ @relation.expects(:qry).with("COUNT(*)").returns([[1982]])
51
+ assert_equal 1982, @relation.count(:all)
52
+ end
44
53
  end
45
54
  end
46
- describe "when not loaded" do
47
- it "uses qry to count the records" do
55
+ describe "when otherwise" do
56
+ it "invokes the original count method" do
57
+ @relation.expects(:loaded?).returns(false)
58
+ @relation.expects(:original_count)
59
+ @relation.count(:foo)
60
+
48
61
  @relation.expects(:loaded?).returns(false)
49
- @relation.expects(:qry).with("COUNT(*)").returns([[1982]])
50
- assert_equal 1982, @relation.size
62
+ @relation.expects(:original_count)
63
+ @relation.count(:all, {:foo => :bar})
51
64
  end
52
65
  end
53
66
  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.9
4
+ version: 0.1.10
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-03-04 00:00:00.000000000 Z
11
+ date: 2015-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord