thoughtbot-pacecar 1.0.0 → 1.0.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/pacecar/helpers.rb +13 -3
- metadata +1 -1
data/lib/pacecar/helpers.rb
CHANGED
|
@@ -13,16 +13,26 @@ module Pacecar
|
|
|
13
13
|
|
|
14
14
|
module ClassMethods
|
|
15
15
|
|
|
16
|
+
protected
|
|
17
|
+
|
|
18
|
+
def safe_columns
|
|
19
|
+
begin
|
|
20
|
+
columns
|
|
21
|
+
rescue ActiveRecord::StatementInvalid # If the table does not exist
|
|
22
|
+
Array.new
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
16
26
|
def column_names
|
|
17
|
-
|
|
27
|
+
safe_columns.collect(&:name)
|
|
18
28
|
end
|
|
19
29
|
|
|
20
30
|
def column_names_for_type(*types)
|
|
21
|
-
|
|
31
|
+
safe_columns.select { |column| types.include? column.type }.collect(&:name)
|
|
22
32
|
end
|
|
23
33
|
|
|
24
34
|
def column_names_without_type(*types)
|
|
25
|
-
|
|
35
|
+
safe_columns.select { |column| ! types.include? column.type }.collect(&:name)
|
|
26
36
|
end
|
|
27
37
|
|
|
28
38
|
def boolean_column_names
|