Sha256: f65072f8163030e1a63eb919716314e79ceacee54c82ea665c4c66e8871f6f5b
Contents?: true
Size: 775 Bytes
Versions: 6
Compression:
Stored size: 775 Bytes
Contents
module Archive2s class Model < ActiveRecord::Base #TODO: drop the id column and use the index set_table_name :archived_to_s belongs_to :model, :polymorphic => true def model archived_model = model_class.new() archived_model.id = self.model_id #can't use self in the instance_eval/define method so make a local variable first return_value = self.archived_value archived_model.instance_eval do singleton = class << self; self; end singleton.send(:define_method, self.class.archive_2s_args[:method_name]) do return_value end end archived_model.readonly! archived_model end def model_class @model_class ||= eval(self.model_type.classify) end end end
Version data entries
6 entries across 6 versions & 1 rubygems