aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/legacy_yaml_adapter.rb18
1 files changed, 17 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/legacy_yaml_adapter.rb b/activerecord/lib/active_record/legacy_yaml_adapter.rb
index 0d018d4352..89dee58423 100644
--- a/activerecord/lib/active_record/legacy_yaml_adapter.rb
+++ b/activerecord/lib/active_record/legacy_yaml_adapter.rb
@@ -7,13 +7,29 @@ module ActiveRecord
when 1 then coder
else
if coder["attributes"].is_a?(AttributeSet)
- coder
+ Rails420.convert(klass, coder)
else
Rails41.convert(klass, coder)
end
end
end
+ module Rails420
+ def self.convert(klass, coder)
+ attribute_set = coder["attributes"]
+
+ klass.attribute_names.each do |attr_name|
+ attribute = attribute_set[attr_name]
+ if attribute.type.is_a?(Delegator)
+ type_from_klass = klass.type_for_attribute(attr_name)
+ attribute_set[attr_name] = attribute.with_type(type_from_klass)
+ end
+ end
+
+ coder
+ end
+ end
+
module Rails41
def self.convert(klass, coder)
attributes = klass.attributes_builder