aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2014-01-29 20:48:43 -0200
committerRafael Mendonça França <rafaelmfranca@gmail.com>2014-01-29 20:48:43 -0200
commit5977e7e4d534463c53af1acef960bccade8c8ecc (patch)
treebe7fbda9ec8d6fc8b048baf4a2df99b740689406
parent6bc179075d95030cee4c143b472345fa7f12b1b9 (diff)
downloadrails-5977e7e4d534463c53af1acef960bccade8c8ecc.tar.gz
rails-5977e7e4d534463c53af1acef960bccade8c8ecc.tar.bz2
rails-5977e7e4d534463c53af1acef960bccade8c8ecc.zip
Aesthetic
-rw-r--r--activerecord/CHANGELOG.md2
-rw-r--r--activerecord/lib/active_record/attribute_methods/serialization.rb11
-rw-r--r--activerecord/test/cases/store_test.rb13
3 files changed, 13 insertions, 13 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md
index 3422474d14..7df4720ea5 100644
--- a/activerecord/CHANGELOG.md
+++ b/activerecord/CHANGELOG.md
@@ -1,4 +1,4 @@
-* ActiveRecord objects can now be correctly dumped, loaded and dumped again without issues.
+* Active Record objects can now be correctly dumped, loaded and dumped again without issues.
Previously, if you did `YAML.dump`, `YAML.load` and then `YAML.dump` again
in an ActiveRecord model that used serialization it would fail at the last
diff --git a/activerecord/lib/active_record/attribute_methods/serialization.rb b/activerecord/lib/active_record/attribute_methods/serialization.rb
index 93e3ca8000..67abbbc2a0 100644
--- a/activerecord/lib/active_record/attribute_methods/serialization.rb
+++ b/activerecord/lib/active_record/attribute_methods/serialization.rb
@@ -76,7 +76,6 @@ module ActiveRecord
end
class Attribute < Struct.new(:coder, :value, :state) # :nodoc:
-
def unserialized_value(v = value)
state == :serialized ? unserialize(v) : value
end
@@ -167,12 +166,12 @@ module ActiveRecord
end
def attributes_for_coder
- attribute_names.each_with_object({}) do |name,attrs|
+ attribute_names.each_with_object({}) do |name, attrs|
attrs[name] = if self.class.serialized_attributes.include?(name)
- @attributes[name].serialized_value
- else
- read_attribute(name)
- end
+ @attributes[name].serialized_value
+ else
+ read_attribute(name)
+ end
end
end
end
diff --git a/activerecord/test/cases/store_test.rb b/activerecord/test/cases/store_test.rb
index e24df6abe9..978cee9cfb 100644
--- a/activerecord/test/cases/store_test.rb
+++ b/activerecord/test/cases/store_test.rb
@@ -175,18 +175,19 @@ class StoreTest < ActiveRecord::TestCase
"preferences" => "--- !ruby/hash:ActiveSupport::HashWithIndifferentAccess\nremember_login: true\n",
"json_data" => "{\"height\":\"tall\"}", "json_data_empty"=>"{\"is_a_good_guy\":true}",
"params" => "--- !ruby/hash:ActiveSupport::HashWithIndifferentAccess {}\n",
- "account_id"=> @john.account_id }
+ "account_id"=> @john.account_id
+ }
+
assert_equal attributes, @john.attributes_for_coder
end
test "dump, load and dump again a model" do
- dumped = YAML.dump( @john )
- loaded = YAML.load( dumped )
+ dumped = YAML.dump(@john)
+ loaded = YAML.load(dumped)
assert_equal @john, loaded
- second_dump = YAML.dump( loaded )
+ second_dump = YAML.dump(loaded)
assert_equal dumped, second_dump
- assert_equal @john, YAML.load( second_dump )
+ assert_equal @john, YAML.load(second_dump)
end
-
end