From 0bf51e9805260243ec0bbe5fca8f8b9364fdd970 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Wed, 4 Jan 2012 12:55:11 -0300 Subject: No need to check if YAML::ENGINE is defined since ruby 1.9 does that --- activerecord/lib/active_record/core.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord') diff --git a/activerecord/lib/active_record/core.rb b/activerecord/lib/active_record/core.rb index 980f8fe50f..ee7ff7a2d7 100644 --- a/activerecord/lib/active_record/core.rb +++ b/activerecord/lib/active_record/core.rb @@ -319,7 +319,7 @@ module ActiveRecord # Hackery to accomodate Syck. Remove for 4.0. def to_yaml(opts = {}) #:nodoc: - if YAML.const_defined?(:ENGINE) && !YAML::ENGINE.syck? + if !YAML::ENGINE.syck? super else coder = {} -- cgit v1.2.3 From 761b049b2e51a035eaf9c18f4d0200409848a28e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Wed, 4 Jan 2012 13:30:57 -0300 Subject: No need to use rescue block to require psych --- activerecord/lib/active_record/base.rb | 6 +--- activerecord/lib/active_record/fixtures.rb | 7 +---- activerecord/lib/active_record/fixtures/file.rb | 6 +--- activerecord/test/cases/yaml_serialization_test.rb | 32 ++++++++++------------ 4 files changed, 17 insertions(+), 34 deletions(-) (limited to 'activerecord') diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index d29cf82dad..5ce78ca1c6 100644 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -1,8 +1,4 @@ -begin - require 'psych' -rescue LoadError -end - +require 'psych' require 'yaml' require 'set' require 'active_support/benchmarkable' diff --git a/activerecord/lib/active_record/fixtures.rb b/activerecord/lib/active_record/fixtures.rb index 9ea8cf864c..8ae09d3e27 100644 --- a/activerecord/lib/active_record/fixtures.rb +++ b/activerecord/lib/active_record/fixtures.rb @@ -1,10 +1,5 @@ require 'erb' - -begin - require 'psych' -rescue LoadError -end - +require 'psych' require 'yaml' require 'zlib' require 'active_support/dependencies' diff --git a/activerecord/lib/active_record/fixtures/file.rb b/activerecord/lib/active_record/fixtures/file.rb index 6bad36abb9..f6fc883ee0 100644 --- a/activerecord/lib/active_record/fixtures/file.rb +++ b/activerecord/lib/active_record/fixtures/file.rb @@ -1,8 +1,4 @@ -begin - require 'psych' -rescue LoadError -end - +require 'psych' require 'erb' require 'yaml' diff --git a/activerecord/test/cases/yaml_serialization_test.rb b/activerecord/test/cases/yaml_serialization_test.rb index 2b4ec81199..dfdb27e5ab 100644 --- a/activerecord/test/cases/yaml_serialization_test.rb +++ b/activerecord/test/cases/yaml_serialization_test.rb @@ -1,4 +1,5 @@ -require "cases/helper" +require 'psych' +require 'cases/helper' require 'models/topic' class YamlSerializationTest < ActiveRecord::TestCase @@ -36,22 +37,17 @@ class YamlSerializationTest < ActiveRecord::TestCase assert_equal({'attributes' => topic.attributes}, coder) end - begin - require 'psych' - - def test_psych_roundtrip - topic = Topic.first - assert topic - t = Psych.load Psych.dump topic - assert_equal topic, t - end - - def test_psych_roundtrip_new_object - topic = Topic.new - assert topic - t = Psych.load Psych.dump topic - assert_equal topic.attributes, t.attributes - end - rescue LoadError + def test_psych_roundtrip + topic = Topic.first + assert topic + t = Psych.load Psych.dump topic + assert_equal topic, t + end + + def test_psych_roundtrip_new_object + topic = Topic.new + assert topic + t = Psych.load Psych.dump topic + assert_equal topic.attributes, t.attributes end end -- cgit v1.2.3 From bdc49dcb4ee2af23599965e98fec1bfe21561c23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Wed, 4 Jan 2012 14:28:01 -0300 Subject: No need to override to_yaml and yaml_initialize methods in ActiveRecord::Core --- activerecord/lib/active_record/core.rb | 20 -------------------- 1 file changed, 20 deletions(-) (limited to 'activerecord') diff --git a/activerecord/lib/active_record/core.rb b/activerecord/lib/active_record/core.rb index ee7ff7a2d7..0755379a74 100644 --- a/activerecord/lib/active_record/core.rb +++ b/activerecord/lib/active_record/core.rb @@ -317,26 +317,6 @@ module ActiveRecord "#<#{self.class} #{inspection}>" end - # Hackery to accomodate Syck. Remove for 4.0. - def to_yaml(opts = {}) #:nodoc: - if !YAML::ENGINE.syck? - super - else - coder = {} - encode_with(coder) - YAML.quick_emit(self, opts) do |out| - out.map(taguri, to_yaml_style) do |map| - coder.each { |k, v| map.add(k, v) } - end - end - end - end - - # Hackery to accomodate Syck. Remove for 4.0. - def yaml_initialize(tag, coder) #:nodoc: - init_with(coder) - end - private # Under Ruby 1.9, Array#flatten will call #to_ary (recursively) on each of the elements -- cgit v1.2.3 From 7d26fad384a99aea27e478474f5b8d24ae33b704 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Wed, 4 Jan 2012 14:29:13 -0300 Subject: No need to require psych since require yaml does that. --- activerecord/lib/active_record/base.rb | 1 - activerecord/lib/active_record/fixtures.rb | 1 - activerecord/lib/active_record/fixtures/file.rb | 1 - activerecord/test/cases/yaml_serialization_test.rb | 1 - 4 files changed, 4 deletions(-) (limited to 'activerecord') diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 5ce78ca1c6..5c8dbd1b47 100644 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -1,4 +1,3 @@ -require 'psych' require 'yaml' require 'set' require 'active_support/benchmarkable' diff --git a/activerecord/lib/active_record/fixtures.rb b/activerecord/lib/active_record/fixtures.rb index 8ae09d3e27..339ba1e19e 100644 --- a/activerecord/lib/active_record/fixtures.rb +++ b/activerecord/lib/active_record/fixtures.rb @@ -1,5 +1,4 @@ require 'erb' -require 'psych' require 'yaml' require 'zlib' require 'active_support/dependencies' diff --git a/activerecord/lib/active_record/fixtures/file.rb b/activerecord/lib/active_record/fixtures/file.rb index f6fc883ee0..6547791144 100644 --- a/activerecord/lib/active_record/fixtures/file.rb +++ b/activerecord/lib/active_record/fixtures/file.rb @@ -1,4 +1,3 @@ -require 'psych' require 'erb' require 'yaml' diff --git a/activerecord/test/cases/yaml_serialization_test.rb b/activerecord/test/cases/yaml_serialization_test.rb index dfdb27e5ab..302913e095 100644 --- a/activerecord/test/cases/yaml_serialization_test.rb +++ b/activerecord/test/cases/yaml_serialization_test.rb @@ -1,4 +1,3 @@ -require 'psych' require 'cases/helper' require 'models/topic' -- cgit v1.2.3