Class: Divert::Redirect

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/divert/redirect.rb

Constant Summary collapse

ANTISLASH =
/^\/|\/\s*$/

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.hit(path) ⇒ Object

Class Methods



26
27
28
29
30
31
# File 'app/models/divert/redirect.rb', line 26

def self.hit path
  find_or_create_by_hither(
    path.gsub ANTISLASH,
    :hither => path, :hits => 0
  ).hit
end

Instance Method Details

#hitObject



19
20
21
22
23
# File 'app/models/divert/redirect.rb', line 19

def hit
  return nil unless active
  self.increment! :hits unless self.thither
  self.thither
end

#nameObject

Instance Methods



15
16
17
# File 'app/models/divert/redirect.rb', line 15

def name
  "\"#{hither}\" > \"#{thither}\""
end