Sha256: aa7c8e1b46869caf2d66e64a19c702d11629ad3fb7da4c0e0c4c3842f5e414e0
Contents?: true
Size: 1.15 KB
Versions: 1
Compression:
Stored size: 1.15 KB
Contents
module GIGO module ActiveRecord module Base def gigo_serialized_attribute(*attrs) attrs.each do |attr| yaml_column = self.serialized_attributes[attr.to_s] next unless yaml_column yaml_column.class_eval do def load_with_gigo(yaml) existing_encoding = Encoding.default_internal Encoding.default_internal = GIGO.encoding yaml = GIGO.load(yaml) load_without_gigo(yaml) ensure Encoding.default_internal = existing_encoding end alias_method_chain :load, :gigo end end end def gigo_column(*attrs) mod = begin if defined?(GIGOColumns) const_get(:GIGOColumns) else m = const_set(:GIGOColumns, Module.new) include m m end end attrs.each do |attr| mod.module_eval <<-CODE, __FILE__, __LINE__ def #{attr} GIGO.load(super) end CODE end end end end end ActiveRecord::Base.extend GIGO::ActiveRecord::Base
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gigo-activerecord-1.0.0 | lib/gigo/active_record/base.rb |