diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2017-11-09 15:12:38 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-09 15:12:38 -0500 |
commit | 100c62ae15deb3d70c5e17d880fd57971bb8759a (patch) | |
tree | 736119c8ea9b683ac465c07e6a640d7e14bbc1b0 /activerecord/lib/active_record/attribute_set/yaml_encoder.rb | |
parent | dac7c8844b4d9944eaa0fca98b45ee478cdb7201 (diff) | |
parent | c3675f50d2e59b7fc173d7b332860c4b1a24a726 (diff) | |
download | rails-100c62ae15deb3d70c5e17d880fd57971bb8759a.tar.gz rails-100c62ae15deb3d70c5e17d880fd57971bb8759a.tar.bz2 rails-100c62ae15deb3d70c5e17d880fd57971bb8759a.zip |
Merge pull request #30985 from lugray/attribute_set_in_am
Move Attribute and AttributeSet to ActiveModel
Diffstat (limited to 'activerecord/lib/active_record/attribute_set/yaml_encoder.rb')
-rw-r--r-- | activerecord/lib/active_record/attribute_set/yaml_encoder.rb | 43 |
1 files changed, 0 insertions, 43 deletions
diff --git a/activerecord/lib/active_record/attribute_set/yaml_encoder.rb b/activerecord/lib/active_record/attribute_set/yaml_encoder.rb deleted file mode 100644 index 9254ce16ab..0000000000 --- a/activerecord/lib/active_record/attribute_set/yaml_encoder.rb +++ /dev/null @@ -1,43 +0,0 @@ -# frozen_string_literal: true - -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 # :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| - if attr.type.equal?(default_types[attr.name]) - attr.with_type(nil) - else - attr - end - end - end - - def decode(coder) - if coder["attributes"] - coder["attributes"] - else - attributes_hash = Hash[coder["concise_attributes"].map do |attr| - if attr.type.nil? - attr = attr.with_type(default_types[attr.name]) - end - [attr.name, attr] - end] - AttributeSet.new(attributes_hash) - 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 - end - end -end |