<commit_before>class Memento::State < ActiveRecord::Base
  set_table_name "memento_states"
  
  belongs_to :session, :class_name => "Memento::Session"
  belongs_to :record, :polymorphic => true
  
  validates_presence_of :session
  validates_presence_of :record
  validates_presence_of :action_type
  validates_inclusion_of :action_type, :in => Memento::Action::Base.action_types, :allow_blank => true
  
  before_create :set_record_data
  
  def self.store(action_type, record)
    self.new(:action_type => action_type.to_s, :record => record) do |state|
      state.save if state.fetch?
    end
  end
  
  def undo
    Memento::Result.new(action.undo, self)
  end
  
  def record_data
    @record_data ||= Marshal.load(super)
  end
  
  def record_data=(data)
    @record_data = nil
    super(Marshal.dump(data))
  end
  
  def fetch?
    action.fetch?
  end
  
  private
  
  def set_record_data
    self.record_data = action.fetch
  end
  
  def action
    "memento/action/#{action_type}".classify.constantize.new(self)
  end
  
end<commit_msg>Used read/write_attribute instead of super<commit_after>class Memento::State < ActiveRecord::Base
  set_table_name "memento_states"
  
  belongs_to :session, :class_name => "Memento::Session"
  belongs_to :record, :polymorphic => true
  
  validates_presence_of :session
  validates_presence_of :record
  validates_presence_of :action_type
  validates_inclusion_of :action_type, :in => Memento::Action::Base.action_types, :allow_blank => true
  
  before_create :set_record_data
  
  def self.store(action_type, record)
    self.new(:action_type => action_type.to_s, :record => record) do |state|
      state.save if state.fetch?
    end
  end
  
  def undo
    Memento::Result.new(action.undo, self)
  end
  
  def record_data
    @record_data ||= Marshal.load(read_attribute(:record_data))
  end
  
  def record_data=(data)
    @record_data = nil
    write_attribute(:record_data, Marshal.dump(data))
  end
  
  def fetch?
    action.fetch?
  end
  
  private
  
  def set_record_data
    self.record_data = action.fetch
  end
  
  def action
    "memento/action/#{action_type}".classify.constantize.new(self)
  end
  
end
{'fraction_non_alphanumeric': 0.09852670349907919, 'fraction_numerical': 0.0, 'mean_word_length': 3.7969094922737305, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5790758', 'n_tokens_mistral': 779, 'n_tokens_neox': 778, 'n_words': 148}