Class: DatashiftJourney::BackLink

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers::UrlHelper
Defined in:
lib/datashift_journey/helpers/back_link.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request, engine_routes:, journey_plan: nil, css: nil) ⇒ BackLink

Returns a new instance of BackLink.



12
13
14
15
16
17
# File 'lib/datashift_journey/helpers/back_link.rb', line 12

def initialize(request, engine_routes:, journey_plan: nil, css: nil)
  @current_request = request
  @engine_routes = engine_routes
  @journey_plan = journey_plan
  @css = css
end

Instance Attribute Details

#cssObject (readonly)

Returns the value of attribute css.



10
11
12
# File 'lib/datashift_journey/helpers/back_link.rb', line 10

def css
  @css
end

#current_requestObject (readonly)

Returns the value of attribute current_request.



10
11
12
# File 'lib/datashift_journey/helpers/back_link.rb', line 10

def current_request
  @current_request
end

#engine_routesObject (readonly)

Returns the value of attribute engine_routes.



10
11
12
# File 'lib/datashift_journey/helpers/back_link.rb', line 10

def engine_routes
  @engine_routes
end

#journey_planObject (readonly)

Returns the value of attribute journey_plan.



10
11
12
# File 'lib/datashift_journey/helpers/back_link.rb', line 10

def journey_plan
  @journey_plan
end

Instance Method Details

#tag(text = nil, html_opts = {}) ⇒ Object



19
20
21
22
23
24
# File 'lib/datashift_journey/helpers/back_link.rb', line 19

def tag(text = nil, html_opts = {})
  if journey_plan && (journey_plan.can_back?)
    title, url = link_arguments(text)
    link_to title, url, html_opts.merge(class: css || 'journey-plan-back-link')
  end
end