1module FormTracking
 
2  extend ActiveSupport::Concern
 
3
 
4  private
 
5
  • UtilityFunction - doesn't depend on instance state (maybe move it to another class?) » reek
  • Complexity 1 » saikuro
6  def generate_form_token
 
7    Authlogic::Random.friendly_token
 
8  end
 
 9
  • Complexity 1 » saikuro
10  def build_form_request
 
11    { "form_token" => generate_form_token, "form_requested_at" => current_time }
 
12  end
 
  • Complexity 1 » saikuro
14  def form_request_id
 
15    petition_id.to_s
 
16  end
 
  • DuplicateMethodCall - calls 'session["form_requests"]' 2 times » reek
  • Complexity 1 » saikuro
18  def form_requests
 
19    session["form_requests"] ||= {}
 
20    session["form_requests"]
 
21  end
 
  • DuplicateMethodCall - calls 'form_requests[form_request_id]' 2 times » reek
  • Complexity 1 » saikuro
23  def form_request
 
24    form_requests[form_request_id] ||= build_form_request
 
25    form_requests[form_request_id]
 
26  end
 
  • Complexity 1 » saikuro
28  def form_token
 
29    form_request["form_token"]
 
30  end
 
  • Complexity 1 » saikuro
32  def form_requested_at
 
33    form_request["form_requested_at"]
 
34  end
 
  • Complexity 1 » saikuro
36  def image_loaded_at
 
37    cookies.encrypted[form_token]
 
38  end
 
39end