aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/core.rb
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2014-12-29 11:07:56 -0700
committerSean Griffin <sean@thoughtbot.com>2014-12-29 11:07:56 -0700
commitfb6df2ac46a82f02a6a620953e04cd834bc7f887 (patch)
tree18b711895fb8626a9a1407864d12cd97d2f62cda /activerecord/lib/active_record/core.rb
parent7eed50c7208a1b605e6ad04e877a3cbeb7cc3434 (diff)
downloadrails-fb6df2ac46a82f02a6a620953e04cd834bc7f887.tar.gz
rails-fb6df2ac46a82f02a6a620953e04cd834bc7f887.tar.bz2
rails-fb6df2ac46a82f02a6a620953e04cd834bc7f887.zip
Extract an explicit type caster class
Diffstat (limited to 'activerecord/lib/active_record/core.rb')
-rw-r--r--activerecord/lib/active_record/core.rb12
1 files changed, 5 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/core.rb b/activerecord/lib/active_record/core.rb
index 51c90a9d9d..3f714397d2 100644
--- a/activerecord/lib/active_record/core.rb
+++ b/activerecord/lib/active_record/core.rb
@@ -235,7 +235,7 @@ module ActiveRecord
# scope :published_and_commented, -> { published.and(self.arel_table[:comments_count].gt(0)) }
# end
def arel_table # :nodoc:
- @arel_table ||= Arel::Table.new(table_name, type_caster: self)
+ @arel_table ||= Arel::Table.new(table_name, type_caster: type_caster)
end
# Returns the Arel engine.
@@ -252,12 +252,6 @@ module ActiveRecord
@predicate_builder ||= PredicateBuilder.new(table_metadata)
end
- def type_cast_for_database(attribute_name, value)
- return value if value.is_a?(Arel::Nodes::BindParam)
- type = type_for_attribute(attribute_name.to_s)
- type.type_cast_for_database(value)
- end
-
private
def relation # :nodoc:
@@ -273,6 +267,10 @@ module ActiveRecord
def table_metadata # :nodoc:
TableMetadata.new(self, arel_table)
end
+
+ def type_caster # :nodoc:
+ TypeCaster::Map.new(self)
+ end
end
# New objects can be instantiated as either empty (pass no construction parameter) or pre-set with