/usr/lib/ruby/vendor_ruby/active_record/coders/yaml_column.rb is in ruby-activerecord-3.2 3.2.16-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | module ActiveRecord
# :stopdoc:
module Coders
class YAMLColumn
RESCUE_ERRORS = [ ArgumentError ]
if defined?(Psych) && defined?(Psych::SyntaxError)
RESCUE_ERRORS << Psych::SyntaxError
end
attr_accessor :object_class
def initialize(object_class = Object)
@object_class = object_class
end
def dump(obj)
YAML.dump obj
end
def load(yaml)
return object_class.new if object_class != Object && yaml.nil?
return yaml unless yaml.is_a?(String) && yaml =~ /^---/
begin
obj = YAML.load(yaml)
unless obj.is_a?(object_class) || obj.nil?
raise SerializationTypeMismatch,
"Attribute was supposed to be a #{object_class}, but was a #{obj.class}"
end
obj ||= object_class.new if object_class != Object
obj
rescue *RESCUE_ERRORS
yaml
end
end
end
end
# :startdoc
end
|