diff options
author | Sean Griffin <sean@thoughtbot.com> | 2015-01-27 13:42:02 -0700 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2015-01-27 16:10:03 -0700 |
commit | b06f64c3480cd389d14618540d62da4978918af0 (patch) | |
tree | 626a163d2885fd3b91e58c6bcbf60ec3824a51f0 /activerecord/lib/active_record/relation/query_attribute.rb | |
parent | d66ffb656e0cfbb4216f030c8e0669509567e362 (diff) | |
download | rails-b06f64c3480cd389d14618540d62da4978918af0.tar.gz rails-b06f64c3480cd389d14618540d62da4978918af0.tar.bz2 rails-b06f64c3480cd389d14618540d62da4978918af0.zip |
Remove Relation#bind_params
`bound_attributes` is now used universally across the board, removing
the need for the conversion layer. These changes are mostly mechanical,
with the exception of the log subscriber. Additional, we had to
implement `hash` on the attribute objects, so they could be used as a
key for query caching.
Diffstat (limited to 'activerecord/lib/active_record/relation/query_attribute.rb')
-rw-r--r-- | activerecord/lib/active_record/relation/query_attribute.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/relation/query_attribute.rb b/activerecord/lib/active_record/relation/query_attribute.rb new file mode 100644 index 0000000000..e69319b4de --- /dev/null +++ b/activerecord/lib/active_record/relation/query_attribute.rb @@ -0,0 +1,19 @@ +require 'active_record/attribute' + +module ActiveRecord + class Relation + class QueryAttribute < Attribute + def type_cast(value) + value + end + + def value_for_database + @value_for_database ||= super + end + + def with_cast_value(value) + QueryAttribute.new(name, value, type) + end + end + end +end |