Skip to content

Commit d63ae39

Browse files
committed
Chage the order of method definitions in check.rb in preparation for privatizing methods
1 parent 4db2812 commit d63ae39

File tree

1 file changed

+11
-11
lines changed
  • lib/active_record/postgres/constraints/types

1 file changed

+11
-11
lines changed

lib/active_record/postgres/constraints/types/check.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ module ActiveRecord
44
module Postgres
55
module Constraints
66
class << self
7+
def to_sql(table, name_or_conditions, conditions = nil)
8+
if conditions
9+
name = name_or_conditions
10+
else
11+
name = "#{table}_#{Time.zone.now.nsec}"
12+
conditions = name_or_conditions
13+
end
14+
15+
"CONSTRAINT #{name} CHECK (#{normalize_conditions(conditions)})"
16+
end
17+
718
def normalize_conditions(conditions)
819
conditions = [conditions] unless conditions.is_a?(Array)
920
conditions = conditions.map do |condition|
@@ -26,17 +37,6 @@ def normalize_conditions_hash(hash)
2637
end
2738
"(#{hash.join(') AND (')})"
2839
end
29-
30-
def to_sql(table, name_or_conditions, conditions = nil)
31-
if conditions
32-
name = name_or_conditions
33-
else
34-
name = "#{table}_#{Time.zone.now.nsec}"
35-
conditions = name_or_conditions
36-
end
37-
38-
"CONSTRAINT #{name} CHECK (#{normalize_conditions(conditions)})"
39-
end
4040
end
4141
end
4242
end

0 commit comments

Comments
 (0)