aboutsummaryrefslogtreecommitdiffstats
path: root/test/support/fake_record.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2014-03-24 16:26:09 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2014-03-24 16:26:09 -0700
commit93d72131bcc24ccb5536bec672d2dac94f8de651 (patch)
treeb0bddcce28817906b483c8f73c574d350ac844c4 /test/support/fake_record.rb
parent24995298face1d08ffb52f6c1b0374feeb7a380b (diff)
downloadrails-93d72131bcc24ccb5536bec672d2dac94f8de651.tar.gz
rails-93d72131bcc24ccb5536bec672d2dac94f8de651.tar.bz2
rails-93d72131bcc24ccb5536bec672d2dac94f8de651.zip
add the casting node to the AST at build time
If we add the casting node to the ast at build time, then we can avoid doing the lookup at visit time.
Diffstat (limited to 'test/support/fake_record.rb')
-rw-r--r--test/support/fake_record.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/test/support/fake_record.rb b/test/support/fake_record.rb
index 58883e43cd..ed4420a2cd 100644
--- a/test/support/fake_record.rb
+++ b/test/support/fake_record.rb
@@ -66,6 +66,10 @@ module FakeRecord
end
case thing
+ when DateTime
+ "'#{thing.strftime("%Y-%m-%d %H:%M:%S")}'"
+ when Date
+ "'#{thing.strftime("%Y-%m-%d")}'"
when true
"'t'"
when false
@@ -75,7 +79,7 @@ module FakeRecord
when Numeric
thing
else
- "'#{thing}'"
+ "'#{thing.to_s.gsub("'", "\\\\'")}'"
end
end
end