Permalink
Browse files

Aesthetic

  • Loading branch information...
1 parent 6bc1790 commit 5977e7e4d534463c53af1acef960bccade8c8ecc @rafaelfranca rafaelfranca committed Jan 29, 2014
View
2 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
View
11 activerecord/lib/active_record/attribute_methods/serialization.rb
@@ -76,7 +76,6 @@ def accessor
end
class Attribute < Struct.new(:coder, :value, :state) # :nodoc:
-
def unserialized_value(v = value)
state == :serialized ? unserialize(v) : value
end
@@ -167,12 +166,12 @@ def typecasted_attribute_value(name)
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
View
13 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

0 comments on commit 5977e7e

Please sign in to comment.