From db045dbbf60b53dbe013ef25554fd013baf88134 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 24 Nov 2004 01:04:44 +0000 Subject: Initial git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/lib/active_record/wrappers/yaml_wrapper.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 activerecord/lib/active_record/wrappers/yaml_wrapper.rb (limited to 'activerecord/lib/active_record/wrappers') diff --git a/activerecord/lib/active_record/wrappers/yaml_wrapper.rb b/activerecord/lib/active_record/wrappers/yaml_wrapper.rb new file mode 100644 index 0000000000..74f40a507c --- /dev/null +++ b/activerecord/lib/active_record/wrappers/yaml_wrapper.rb @@ -0,0 +1,15 @@ +require 'yaml' + +module ActiveRecord + module Wrappings #:nodoc: + class YamlWrapper < AbstractWrapper #:nodoc: + def wrap(attribute) attribute.to_yaml end + def unwrap(attribute) YAML::load(attribute) end + end + + module ClassMethods #:nodoc: + # Wraps the attribute in Yaml encoding + def wrap_in_yaml(*attributes) wrap_with(YamlWrapper, attributes) end + end + end +end \ No newline at end of file -- cgit v1.2.3