Class: ActiveTools::ActionPack::ActionController::PathHelper::HttpReferer

Inherits:
Object
  • Object
show all
Includes:
ComplexHelpers
Defined in:
lib/active_tools/action_pack/action_controller/path_helper/http_referer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ComplexHelpers

#action?, #controller?, #path?

Constructor Details

#initialize(request, environment = {}) ⇒ HttpReferer

Returns a new instance of HttpReferer.



13
14
15
16
17
18
19
20
21
# File 'lib/active_tools/action_pack/action_controller/path_helper/http_referer.rb', line 13

def initialize(request, environment = {})
  @url = request.env['HTTP_REFERER']
  @recognized = begin
    @url.present? ? Rails.application.routes.recognize_path(@url, environment) : {}
  rescue ::ActionController::RoutingError
    {}
  end
  @recognized.freeze
end

Instance Attribute Details

#recognizedObject (readonly)

Returns the value of attribute recognized.



8
9
10
# File 'lib/active_tools/action_pack/action_controller/path_helper/http_referer.rb', line 8

def recognized
  @recognized
end

#urlObject (readonly)

Returns the value of attribute url.



8
9
10
# File 'lib/active_tools/action_pack/action_controller/path_helper/http_referer.rb', line 8

def url
  @url
end

Instance Method Details

#current_actionObject



27
28
29
# File 'lib/active_tools/action_pack/action_controller/path_helper/http_referer.rb', line 27

def current_action
  recognized[:action]
end

#current_controllerObject



23
24
25
# File 'lib/active_tools/action_pack/action_controller/path_helper/http_referer.rb', line 23

def current_controller
  recognized[:controller]
end

#to_sObject



31
32
33
# File 'lib/active_tools/action_pack/action_controller/path_helper/http_referer.rb', line 31

def to_s
  @url
end