aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/coders/yaml_column.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record/coders/yaml_column.rb')
-rw-r--r--activerecord/lib/active_record/coders/yaml_column.rb17
1 files changed, 8 insertions, 9 deletions
diff --git a/activerecord/lib/active_record/coders/yaml_column.rb b/activerecord/lib/active_record/coders/yaml_column.rb
index 2456b8ad8c..3a04a10fc9 100644
--- a/activerecord/lib/active_record/coders/yaml_column.rb
+++ b/activerecord/lib/active_record/coders/yaml_column.rb
@@ -1,9 +1,8 @@
-require 'yaml'
+require "yaml"
module ActiveRecord
module Coders # :nodoc:
class YAMLColumn # :nodoc:
-
attr_accessor :object_class
def initialize(object_class = Object)
@@ -20,7 +19,7 @@ module ActiveRecord
def load(yaml)
return object_class.new if object_class != Object && yaml.nil?
- return yaml unless yaml.is_a?(String) && yaml =~ /^---/
+ return yaml unless yaml.is_a?(String) && /^---/.match?(yaml)
obj = YAML.load(yaml)
assert_valid_value(obj)
@@ -38,13 +37,13 @@ module ActiveRecord
private
- def check_arity_of_constructor
- begin
- load(nil)
- rescue ArgumentError
- raise ArgumentError, "Cannot serialize #{object_class}. Classes passed to `serialize` must have a 0 argument constructor."
+ def check_arity_of_constructor
+ begin
+ load(nil)
+ rescue ArgumentError
+ raise ArgumentError, "Cannot serialize #{object_class}. Classes passed to `serialize` must have a 0 argument constructor."
+ end
end
- end
end
end
end