aboutsummaryrefslogblamecommitdiffstats
path: root/activerecord/lib/active_record/wrappers/yaml_wrapper.rb
blob: 74f40a507c648ec5246ce5460fe10df9eff426e4 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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