Class: Moonrope::Controller
- Inherits:
-
Object
- Object
- Moonrope::Controller
- Defined in:
- lib/moonrope/controller.rb
Instance Attribute Summary collapse
-
#access ⇒ Object
Returns the value of attribute access.
-
#actions ⇒ Object
Returns the value of attribute actions.
-
#base ⇒ Object
readonly
Returns the value of attribute base.
-
#befores ⇒ Object
Returns the value of attribute befores.
-
#dsl ⇒ Object
readonly
Returns the value of attribute dsl.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
-
#action(action) ⇒ Moonrope::Action
(also: #/)
Lookup and return an action in this controller by name.
-
#before_actions_for(action) ⇒ Array
Return an array of before actions which must be executed for the given action.
-
#initialize(base, name) { ... } ⇒ Controller
constructor
Initalize a new Moonrope::Controller.
Constructor Details
#initialize(base, name) { ... } ⇒ Controller
Initalize a new Moonrope::Controller
14 15 16 17 18 19 20 21 22 |
# File 'lib/moonrope/controller.rb', line 14 def initialize(base, name, &block) @base = base @name = name @actions = {} @access = nil @befores = [] @dsl = Moonrope::DSL::ControllerDSL.new(self) @dsl.instance_eval(&block) if block_given? end |
Instance Attribute Details
#access ⇒ Object
Returns the value of attribute access.
4 5 6 |
# File 'lib/moonrope/controller.rb', line 4 def access @access end |
#actions ⇒ Object
Returns the value of attribute actions.
4 5 6 |
# File 'lib/moonrope/controller.rb', line 4 def actions @actions end |
#base ⇒ Object (readonly)
Returns the value of attribute base.
5 6 7 |
# File 'lib/moonrope/controller.rb', line 5 def base @base end |
#befores ⇒ Object
Returns the value of attribute befores.
4 5 6 |
# File 'lib/moonrope/controller.rb', line 4 def befores @befores end |
#dsl ⇒ Object (readonly)
Returns the value of attribute dsl.
5 6 7 |
# File 'lib/moonrope/controller.rb', line 5 def dsl @dsl end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/moonrope/controller.rb', line 4 def name @name end |
Instance Method Details
#action(action) ⇒ Moonrope::Action Also known as: /
Lookup and return an action in this controller by name.
43 44 45 |
# File 'lib/moonrope/controller.rb', line 43 def action(action) actions[action.to_sym] end |
#before_actions_for(action) ⇒ Array
Return an array of before actions which must be executed for the given action.
31 32 33 34 35 |
# File 'lib/moonrope/controller.rb', line 31 def before_actions_for(action) @befores.select do |b| b.actions.empty? || b.actions.include?(action) end end |