Class: Moonrope::Controller
- Inherits:
-
Object
- Object
- Moonrope::Controller
- Defined in:
- lib/moonrope/controller.rb
Instance Attribute Summary collapse
-
#access_rule ⇒ Object
Returns the value of attribute access_rule.
-
#actions ⇒ Object
Returns the value of attribute actions.
-
#authenticator ⇒ Object
Returns the value of attribute authenticator.
-
#base ⇒ Object
readonly
Returns the value of attribute base.
-
#befores ⇒ Object
Returns the value of attribute befores.
-
#description ⇒ Object
Returns the value of attribute description.
-
#doc ⇒ Object
Returns the value of attribute doc.
-
#dsl ⇒ Object
readonly
Returns the value of attribute dsl.
-
#friendly_name ⇒ Object
Returns the value of attribute friendly_name.
-
#name ⇒ Object
Returns the value of attribute name.
-
#shared_actions ⇒ Object
Returns the value of attribute shared_actions.
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
16 17 18 19 20 21 22 23 24 |
# 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 |
Instance Attribute Details
#access_rule ⇒ Object
Returns the value of attribute access_rule.
6 7 8 |
# File 'lib/moonrope/controller.rb', line 6 def access_rule @access_rule end |
#actions ⇒ Object
Returns the value of attribute actions.
6 7 8 |
# File 'lib/moonrope/controller.rb', line 6 def actions @actions end |
#authenticator ⇒ Object
Returns the value of attribute authenticator.
6 7 8 |
# File 'lib/moonrope/controller.rb', line 6 def authenticator @authenticator end |
#base ⇒ Object (readonly)
Returns the value of attribute base.
7 8 9 |
# File 'lib/moonrope/controller.rb', line 7 def base @base end |
#befores ⇒ Object
Returns the value of attribute befores.
6 7 8 |
# File 'lib/moonrope/controller.rb', line 6 def befores @befores end |
#description ⇒ Object
Returns the value of attribute description.
6 7 8 |
# File 'lib/moonrope/controller.rb', line 6 def description @description end |
#doc ⇒ Object
Returns the value of attribute doc.
6 7 8 |
# File 'lib/moonrope/controller.rb', line 6 def doc @doc end |
#dsl ⇒ Object (readonly)
Returns the value of attribute dsl.
7 8 9 |
# File 'lib/moonrope/controller.rb', line 7 def dsl @dsl end |
#friendly_name ⇒ Object
Returns the value of attribute friendly_name.
6 7 8 |
# File 'lib/moonrope/controller.rb', line 6 def friendly_name @friendly_name end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/moonrope/controller.rb', line 6 def name @name end |
#shared_actions ⇒ Object
Returns the value of attribute shared_actions.
6 7 8 |
# File 'lib/moonrope/controller.rb', line 6 def shared_actions @shared_actions end |
Instance Method Details
#action(action) ⇒ Moonrope::Action Also known as: /
Lookup and return an action in this controller by name.
45 46 47 |
# File 'lib/moonrope/controller.rb', line 45 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.
33 34 35 36 37 |
# 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 |