Class: Tarquinn::Condition Abstract Private

Inherits:
Object
  • Object
show all
Defined in:
lib/tarquinn/condition.rb,
lib/tarquinn/condition/proc_runner.rb,
lib/tarquinn/condition/method_caller.rb,
lib/tarquinn/condition/action_checker.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.

This class is abstract.

Redirection condition

Direct Known Subclasses

ActionChecker, MethodCaller, ProcRunner

Defined Under Namespace

Classes: ActionChecker, MethodCaller, ProcRunner

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.action_checker(routes) ⇒ Tarquinn::Condition::ActionChecker

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.

Creates an action checker condition

Parameters:

  • routes (Array<Symbol>)

    controller actions that will match the condition

Returns:



31
32
33
# File 'lib/tarquinn/condition.rb', line 31

def action_checker(routes)
  Tarquinn::Condition::ActionChecker.new(routes)
end

.method_caller(methods) ⇒ Tarquinn::Condition::MethodCaller, NilClass

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.

Creates a method caller condition

Parameters:

  • methods (Array<Symbol>)

    list of methods to be called for condition

Returns:



20
21
22
23
24
# File 'lib/tarquinn/condition.rb', line 20

def method_caller(methods)
  return if methods.empty?

  Tarquinn::Condition::MethodCaller.new(methods)
end

.proc_runner(&block) ⇒ Tarquinn::Condition::ProcRunner, NilClass

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.

Cretes a proc checker

Parameters:

  • block (Proc)

    block to be ran when condition is checked

Returns:



41
42
43
44
45
# File 'lib/tarquinn/condition.rb', line 41

def proc_runner(&block)
  return unless block

  Tarquinn::Condition::ProcRunner.new(&block)
end

Instance Method Details

#check?(_controller) ⇒ TrueClass, FalseClass

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.

Checks if a condition is matched

Parameters:

Returns:

  • (TrueClass)

    When it is a match

  • (FalseClass)

    When it is not a match

Raises:

  • (NotImplementedError)


54
55
56
# File 'lib/tarquinn/condition.rb', line 54

def check?(_controller)
  raise NotImplementedError, 'Needs to be implemented in child class'
end