Module: Tarquinn::ClassMethods

Defined in:
lib/tarquinn/class_methods.rb

Overview

Methods added by Tarquinn

Instance Method Summary collapse

Instance Method Details

#redirection_rule(redirection, *methods) ⇒ Array<Tarquinn::Condition>

Creates a redirection rule

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

Parameters:

  • redirection (Symbol)

    Rule name and method with redirection path

  • 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:



14
15
16
# File 'lib/tarquinn/class_methods.rb', line 14

def redirection_rule(redirection, *methods, &)
  redirector_builder.add_redirection_config(redirection, *methods, &)
end

#redirector_builderRequestHandlerBuilder

Retruns the RequestHandlerBuilder

RequestHandlerBuilder will Carry all the configurations and will create one RequestHandler for each request



44
45
46
# File 'lib/tarquinn/class_methods.rb', line 44

def redirector_builder
  @redirector_builder ||= Tarquinn::RequestHandlerBuilder.new
end

#skip_redirection(redirection, *actions) ⇒ Array<Tarquinn::Condition>

Attaches a condition to skip a redirection based on route (controller action)

When any of the skip rules is met the redirection is skipped

Parameters:

  • redirection (Symbol)

    Rule name to attach the skip condition

  • actions (Array<Symbol>)

    actions / routes to be skipped by redirection rule

Returns:



24
25
26
# File 'lib/tarquinn/class_methods.rb', line 24

def skip_redirection(redirection, *actions)
  redirector_builder.add_skip_action(redirection, *actions)
end

#skip_redirection_rule(redirection, *methods, &block) ⇒ Array

Attaches conditions to skip a redirection

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

Parameters:

  • redirection (Symbol)

    Rule name to attach the skip condition

  • 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



34
35
36
# File 'lib/tarquinn/class_methods.rb', line 34

def skip_redirection_rule(redirection, *methods, &block)
  redirector_builder.add_skip_config(redirection, *methods, block)
end