lib/facemock/database/table.rb in facemock-0.0.5 vs lib/facemock/database/table.rb in facemock-0.0.6
- old
+ new
@@ -207,10 +207,12 @@
end
def self.define_find_by_column(column_name)
self.class_eval <<-EOF
def self.find_by_#{column_name}(value)
+ return nil if value.nil?
+
column_value = case value
when String then "'" + value + "'"
when Time then "'" + value.to_s + "'"
else value.to_s
end
@@ -225,9 +227,11 @@
end
def self.define_find_all_by_column(column_name)
self.class_eval <<-EOF
def self.find_all_by_#{column_name}(value)
+ return [] if value.nil?
+
column_value = case value
when String then "'" + value + "'"
when Time then "'" + value.to_s + "'"
else value.to_s
end