Class: Karafka::Web::Ui::Controllers::Responses::Redirect

Inherits:
Object
  • Object
show all
Defined in:
lib/karafka/web/ui/controllers/responses/redirect.rb

Overview

Representation of a redirect response with optional flash messages

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path = :back, flashes = {}) ⇒ Redirect

Returns a new instance of Redirect.

Parameters:

  • path (String, Symbol) (defaults to: :back)

    relative (without root path) path where we want to be redirected or :back to use referer back

  • flashes (Hash) (defaults to: {})

    hash where key is the flash type and value is the message



15
16
17
18
# File 'lib/karafka/web/ui/controllers/responses/redirect.rb', line 15

def initialize(path = :back, flashes = {})
  @path = path
  @flashes = flashes
end

Instance Attribute Details

#flashesObject (readonly)

Returns the value of attribute flashes.



10
11
12
# File 'lib/karafka/web/ui/controllers/responses/redirect.rb', line 10

def flashes
  @flashes
end

#pathObject (readonly)

Returns the value of attribute path.



10
11
12
# File 'lib/karafka/web/ui/controllers/responses/redirect.rb', line 10

def path
  @path
end

Instance Method Details

#back?Boolean

Returns are we going back via referer and not explicit path.

Returns:

  • (Boolean)

    are we going back via referer and not explicit path



21
22
23
# File 'lib/karafka/web/ui/controllers/responses/redirect.rb', line 21

def back?
  @path == :back
end