aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/attribute_set/yaml_encoder.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record/attribute_set/yaml_encoder.rb')
-rw-r--r--activerecord/lib/active_record/attribute_set/yaml_encoder.rb14
1 files changed, 8 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/attribute_set/yaml_encoder.rb b/activerecord/lib/active_record/attribute_set/yaml_encoder.rb
index 6208048231..899de14792 100644
--- a/activerecord/lib/active_record/attribute_set/yaml_encoder.rb
+++ b/activerecord/lib/active_record/attribute_set/yaml_encoder.rb
@@ -2,13 +2,13 @@ module ActiveRecord
class AttributeSet
# Attempts to do more intelligent YAML dumping of an
# ActiveRecord::AttributeSet to reduce the size of the resulting string
- class YAMLEncoder
+ class YAMLEncoder # :nodoc:
def initialize(default_types)
@default_types = default_types
end
def encode(attribute_set, coder)
- coder['concise_attributes'] = attribute_set.each_value.map do |attr|
+ coder["concise_attributes"] = attribute_set.each_value.map do |attr|
if attr.type.equal?(default_types[attr.name])
attr.with_type(nil)
else
@@ -18,10 +18,10 @@ module ActiveRecord
end
def decode(coder)
- if coder['attributes']
- coder['attributes']
+ if coder["attributes"]
+ coder["attributes"]
else
- attributes_hash = Hash[coder['concise_attributes'].map do |attr|
+ attributes_hash = Hash[coder["concise_attributes"].map do |attr|
if attr.type.nil?
attr = attr.with_type(default_types[attr.name])
end
@@ -31,9 +31,11 @@ module ActiveRecord
end
end
+ # TODO Change this to private once we've dropped Ruby 2.2 support.
+ # Workaround for Ruby 2.2 "private attribute?" warning.
protected
- attr_reader :default_types
+ attr_reader :default_types
end
end
end