lib/metabolical/meta_datum.rb in metabolical-0.0.2 vs lib/metabolical/meta_datum.rb in metabolical-0.0.3
- old
+ new
@@ -1,6 +1,17 @@
+require 'active_record/version'
module Metabolical
class MetaDatum < ActiveRecord::Base
belongs_to :metabolized, :polymorphic => true
- serialize :data
+ if Gem::Version.new(ActiveRecord::VERSION::STRING) >= Gem::Version.new("3.1.0")
+ serialize :data
+ else
+ def data=(val)
+ write_attribute(:data, val.to_yaml)
+ end
+
+ def data
+ read_attribute(:data).blank? ? nil : YAML.load(read_attribute(:data))
+ end
+ end
end
end
\ No newline at end of file