class Moonrope::Controller

Attributes

access_rule[RW]
actions[RW]
authenticator[RW]
base[R]
befores[RW]
description[RW]
doc[RW]
dsl[R]
friendly_name[RW]
name[RW]
shared_actions[RW]

Public Class Methods

new(base, name, &block) click to toggle source

Initalize a new Moonrope::Controller

@param base [Moonrope::Base] the base @param name [Symbol] the name of the controller @yield instance evals the contents within the ControllerDSL

# File lib/moonrope/controller.rb, line 16
def initialize(base, name, &block)
  @base = base
  @name = name
  @actions = {}
  @shared_actions = {}
  @befores = []
  @dsl = Moonrope::DSL::ControllerDSL.new(self)
  @dsl.instance_eval(&block) if block_given?
end

Public Instance Methods

/(action)
Alias for: action
action(action) click to toggle source

Lookup and return an action in this controller by name.

@param action [Symbol] the name of the action @return [Moonrope::Action] the action

# File lib/moonrope/controller.rb, line 45
def action(action)
  actions[action.to_sym]
end
Also aliased as: /
before_actions_for(action) click to toggle source

Return an array of before actions which must be executed for the given action.

@param action [Symbol] the name of the action to return @return [Array] an array of Moonrope::BeforeAction instances

# File lib/moonrope/controller.rb, line 33
def before_actions_for(action)
  @befores.select do |b|
    b.actions.empty? || b.actions.include?(action)
  end
end