1class EmailRequestedReceipt < ActiveRecord::Base
 
2  belongs_to :petition, touch: true
 
3
 
4  validates :petition, presence: true
 
5  validates :petition_id, uniqueness: true
 
6
  • Complexity 2 » saikuro
7  def get(name)
 
8    raise ArgumentError unless valid_timestamp?(name)
 
 9    self[name]
 
10  end
 
  • Complexity 2 » saikuro
12  def set(name, time)
 
13    raise ArgumentError unless valid_timestamp?(name)
 
14    update_column(name, time)
 
15  end
 
 
17  private
  • Complexity 1 » saikuro
18  def valid_timestamp?(name)
 
19    possible_timestamps.include? name
 
20  end
 
  • Complexity 1 » saikuro
22  def possible_timestamps
 
23    @_possiblities ||= attributes.keys - ['id', 'petition_id', 'created_at', 'updated_at']
 
24  end
 
25end