thoughtbot-pacecar 1.1.2 → 1.1.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/README.rdoc +4 -0
- data/lib/pacecar/boolean.rb +11 -0
- metadata +2 -2
data/README.rdoc
CHANGED
|
@@ -108,6 +108,10 @@ Records that are all admins or non-admins...
|
|
|
108
108
|
User.admin
|
|
109
109
|
User.not_admin
|
|
110
110
|
|
|
111
|
+
The "balance" (count of true minus false for column in question)...
|
|
112
|
+
|
|
113
|
+
User.admin_balance
|
|
114
|
+
|
|
111
115
|
= Datetime columns
|
|
112
116
|
|
|
113
117
|
Records approved before or after certain times...
|
data/lib/pacecar/boolean.rb
CHANGED
|
@@ -7,6 +7,7 @@ module Pacecar
|
|
|
7
7
|
module ClassMethods
|
|
8
8
|
def self.extended(base)
|
|
9
9
|
base.send :define_boolean_scopes
|
|
10
|
+
base.send :define_balance_count
|
|
10
11
|
end
|
|
11
12
|
|
|
12
13
|
protected
|
|
@@ -18,6 +19,16 @@ module Pacecar
|
|
|
18
19
|
end
|
|
19
20
|
end
|
|
20
21
|
|
|
22
|
+
def define_balance_count
|
|
23
|
+
boolean_column_names.each do |name|
|
|
24
|
+
self.class_eval %Q{
|
|
25
|
+
def self.#{name}_balance
|
|
26
|
+
#{name}.count - not_#{name}.count
|
|
27
|
+
end
|
|
28
|
+
}
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
21
32
|
end
|
|
22
33
|
end
|
|
23
34
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: thoughtbot-pacecar
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.1.
|
|
4
|
+
version: 1.1.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Matt Jankowski
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
|
|
12
|
-
date: 2009-
|
|
12
|
+
date: 2009-04-08 00:00:00 -07:00
|
|
13
13
|
default_executable:
|
|
14
14
|
dependencies: []
|
|
15
15
|
|