Class: Tarquinn::RedirectionConfig Private

Inherits:
Object
  • Object
show all
Defined in:
lib/tarquinn/redirection_config.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Redirection configuration

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(redirect) ⇒ RedirectionConfig

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of RedirectionConfig.

Parameters:

  • redirect (Symbol)

    redirection name and redirection method



13
14
15
# File 'lib/tarquinn/redirection_config.rb', line 13

def initialize(redirect)
  @redirect = redirect
end

Instance Attribute Details

#redirectObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



10
11
12
# File 'lib/tarquinn/redirection_config.rb', line 10

def redirect
  @redirect
end

Instance Method Details

#add_redirection_rules(*methods, &block) ⇒ Array<Tarquinn::Condition>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Adds conditions to the rule

The rule name defines which method will be called when checking the path of redirection

Parameters:

  • methods (Array<Symbol>)

    Methods that tell that a redirection should be applied

  • block (Proc)

    block that tells if a the redirection should be applied

Returns:



25
26
27
28
# File 'lib/tarquinn/redirection_config.rb', line 25

def add_redirection_rules(*methods, &block)
  redirect_on method_caller(methods)
  redirect_on proc_runner(&block)
end

#add_skip_action(*actions) ⇒ Array<Tarquinn::Condition>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Add rule for skipping on some actions / routes

Parameters:

  • actions (Array<Symbol>)

    actions / routes to be skipped by redirection rule

Returns:



35
36
37
# File 'lib/tarquinn/redirection_config.rb', line 35

def add_skip_action(*actions)
  skip action_checker(actions)
end

#add_skip_rules(*methods, &block) ⇒ Array

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Attaches conditions to skip a redirection

Methods and blocks are ran and if any returns true, the redirec is skipped

Parameters:

  • methods (Array<Symbol>)

    Methods that tell that a redirection should be skipped

  • block (Proc)

    block that tells if a the redirection should be skipped

Returns:

  • (Array)

    Current registered conditions



47
48
49
50
# File 'lib/tarquinn/redirection_config.rb', line 47

def add_skip_rules(*methods, &block)
  skip method_caller(methods)
  skip proc_runner(&block)
end

#redirection_blocksArray<Tarquinn::Condition>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

All blocks that indicate a redirection

Returns:



55
56
57
# File 'lib/tarquinn/redirection_config.rb', line 55

def redirection_blocks
  @redirection_blocks ||= []
end

#skip_blocksArray<Tarquinn::Condition>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

All blocks that indicate a redirection should be skipped

Returns:



62
63
64
# File 'lib/tarquinn/redirection_config.rb', line 62

def skip_blocks
  @skip_blocks ||= []
end