Module: Vedeu::Controller::SingletonMethods

Defined in:
lib/vedeu/application/controller.rb

Overview

Provide additional behaviour as singleton methods to the including class or module.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#controller_name=(value) ⇒ Object (writeonly)

Sets the attribute controller_name

Parameters:

  • value

    the value to set the attribute controller_name to.



12
13
14
# File 'lib/vedeu/application/controller.rb', line 12

def controller_name=(value)
  @controller_name = value
end

Instance Method Details

#action(*action_names) ⇒ Array<Symbol> Also known as: action_name, actions

Specifying the action names in your controller provides Vedeu with the means to route requests to different parts of your application.

Examples:

class YourController

  controller :your_controller

  action :show
  # or...
  actions :show, :list
  # or...
  action_name :show

  # ... some code

end

Vedeu.trigger(:_goto_,
              :your_controller,
              :show,
              { some: :args })

Parameters:

  • action_names (Array<Symbol>, Symbol)

    A collection of action names or the name of the action.

Returns:

  • (Array<Symbol>)


67
68
69
70
71
# File 'lib/vedeu/application/controller.rb', line 67

def action(*action_names)
  action_names.each do |action_name|
    Vedeu::Runtime::Router.add_action(@controller_name, action_name)
  end
end

#controller(controller_name = nil) ⇒ Object Also known as: controller_name

Specifying the controller name in your controller provides Vedeu with the means to route requests to different parts of your application.

Examples:

class YourController

  controller :your_controller
  # or...
  controller_name :your_controller

  # ... some code

end

Parameters:

  • controller_name (Symbol) (defaults to: nil)

    The name of the controller.

Returns:

  • Hash<Symbol => Hash<Symbol => String, Array<Symbol>>>


32
33
34
35
36
37
# File 'lib/vedeu/application/controller.rb', line 32

def controller(controller_name = nil)
  @controller_name = controller_name

  Vedeu::Runtime::Router.add_controller(controller_name,
                                        ancestors[0].to_s)
end