Class: Tarquinn::Controller Private

Inherits:
Object
  • Object
show all
Defined in:
lib/tarquinn/controller.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.

Controller interface

Instance Method Summary collapse

Constructor Details

#initialize(controller) ⇒ Controller

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 Controller.



8
9
10
# File 'lib/tarquinn/controller.rb', line 8

def initialize(controller)
  @controller = controller
end

Instance Method Details

#call(method, *args, **opts, &block) ⇒ Object

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.

Calls a method from the controller

Parameters:

  • method (Symbol)

    method name to be called

  • args (Array<Symbol>)

    Method arguments

  • opts (Hash<Symbol,Object>)

    Method arguments

  • block (Proc)

    block to be given to the method

Returns:

  • (Object)


27
28
29
# File 'lib/tarquinn/controller.rb', line 27

def call(method, *args, **opts, &block)
  controller.send(method, *args, **opts, &block)
end

#method?(method) ⇒ 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 the controller responds to a method

Parameters:

  • method (Symbol)

    method name

Returns:

  • (TrueClass)

    the controller responds to this method

  • (FalseClass)

    the controller does not responds to this method



46
47
48
# File 'lib/tarquinn/controller.rb', line 46

def method?(method)
  controller.respond_to?(method, true)
end

#paramsActionController::Parameters

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 request parameters

Returns:

  • (ActionController::Parameters)


15
16
17
# File 'lib/tarquinn/controller.rb', line 15

def params
  @params ||= controller.send(:params)
end

#run(&block) ⇒ Object

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.

Run a block in teh context of the controller

Parameters:

  • block (Proc)

    block to be ran

Returns:

  • (Object)

    the return of the block



36
37
38
# File 'lib/tarquinn/controller.rb', line 36

def run(&block)
  controller.send(:instance_eval, &block)
end