Module: Redirector

Defined in:
lib/redirector.rb

Class Method Summary collapse

Class Method Details

.find_logs(shortened_id) ⇒ Object

finds logs associated with the shortened url



5
6
7
# File 'lib/redirector.rb', line 5

def Redirector.find_logs shortened_id
  RedirectLog.where(:redirect_id => find_redirect_by_shortened_id(shortened_id)).to_a
end

.find_redirect_by_shortened_id(shortened_id) ⇒ Object



15
16
17
# File 'lib/redirector.rb', line 15

def Redirector.find_redirect_by_shortened_id shortened_id
  Redirect.where(:shortened_id => shortened_id).to_a.last._id
end

.number_of_redirect_hits(shortened_id) ⇒ Object

finds the number of times a redirect has been accessed



11
12
13
# File 'lib/redirector.rb', line 11

def Redirector.number_of_redirect_hits shortened_id
  RedirectLog.where(:redirect_id => find_redirect_by_shortened_id(shortened_id)).count
end