diff options
Diffstat (limited to 'activerecord/lib/active_record/wrappers/yaml_wrapper.rb')
-rw-r--r-- | activerecord/lib/active_record/wrappers/yaml_wrapper.rb | 15 |
1 files changed, 15 insertions, 0 deletions
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 |