From 14b1208dd313f643f72aa2d92874198342e9fe14 Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Sun, 22 Jun 2014 16:25:40 -0600 Subject: Encapsulate the creation of `Attribute` objects This will make it less painful to add additional properties, which should persist across writes, such as `name`. Conflicts: activerecord/lib/active_record/attribute_set.rb --- activerecord/lib/active_record/attribute_set.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'activerecord/lib/active_record/attribute_set.rb') diff --git a/activerecord/lib/active_record/attribute_set.rb b/activerecord/lib/active_record/attribute_set.rb index 68382756a4..65e15b16dd 100644 --- a/activerecord/lib/active_record/attribute_set.rb +++ b/activerecord/lib/active_record/attribute_set.rb @@ -2,7 +2,7 @@ require 'active_record/attribute_set/builder' module ActiveRecord class AttributeSet # :nodoc: - delegate :[], :[]=, to: :attributes + delegate :[], to: :attributes delegate :keys, to: :initialized_attributes def initialize(attributes) @@ -31,6 +31,14 @@ module ActiveRecord end end + def write_from_database(name, value) + attributes[name] = self[name].with_value_from_database(value) + end + + def write_from_user(name, value) + attributes[name] = self[name].with_value_from_user(value) + end + def freeze @attributes.freeze super -- cgit v1.2.3