Class: Aldous::ControllerAction
- Inherits:
-
Object
- Object
- Aldous::ControllerAction
- Includes:
- Aldous
- Defined in:
- lib/aldous/controller_action.rb
Constant Summary
Constants included from Aldous
Instance Attribute Summary collapse
-
#controller ⇒ Object
readonly
Returns the value of attribute controller.
Class Method Summary collapse
Instance Method Summary collapse
-
#build_view(respondable_class, extra_data = {}) ⇒ Object
NOTE deprecated.
- #default_error_handler(error) ⇒ Object
- #default_view_data ⇒ Object
-
#initialize(controller, view_builder = nil) ⇒ ControllerAction
constructor
A new instance of ControllerAction.
- #perform ⇒ Object
- #preconditions ⇒ Object
- #view_builder ⇒ Object
Methods included from Aldous
Constructor Details
#initialize(controller, view_builder = nil) ⇒ ControllerAction
Returns a new instance of ControllerAction.
33 34 35 36 |
# File 'lib/aldous/controller_action.rb', line 33 def initialize(controller, view_builder = nil) @controller = controller @view_builder = view_builder end |
Instance Attribute Details
#controller ⇒ Object (readonly)
Returns the value of attribute controller.
31 32 33 |
# File 'lib/aldous/controller_action.rb', line 31 def controller @controller end |
Class Method Details
.build(controller) ⇒ Object
11 12 13 |
# File 'lib/aldous/controller_action.rb', line 11 def build(controller) Aldous::Controller::Action::Wrapper.new(new(controller)) end |
.inherited(klass) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/aldous/controller_action.rb', line 19 def inherited(klass) # expose methods from controller to the service, according to configuration ::Aldous.configuration.controller_methods_exposed_to_action.each do |method_name| unless klass.method_defined?(method_name) define_method method_name do controller.send(method_name) end end end end |
.perform(controller) ⇒ Object
15 16 17 |
# File 'lib/aldous/controller_action.rb', line 15 def perform(controller) build(controller).perform end |
Instance Method Details
#build_view(respondable_class, extra_data = {}) ⇒ Object
NOTE deprecated
61 62 63 |
# File 'lib/aldous/controller_action.rb', line 61 def build_view(respondable_class, extra_data = {}) # deprecated view_builder.build(respondable_class, extra_data) end |
#default_error_handler(error) ⇒ Object
50 51 52 |
# File 'lib/aldous/controller_action.rb', line 50 def default_error_handler(error) ::Aldous::View::Blank::HtmlView end |
#default_view_data ⇒ Object
42 43 44 |
# File 'lib/aldous/controller_action.rb', line 42 def default_view_data {} end |
#perform ⇒ Object
38 39 40 |
# File 'lib/aldous/controller_action.rb', line 38 def perform raise NotImplementedError.new("#{self.class.name} must implement method #perform") end |
#preconditions ⇒ Object
46 47 48 |
# File 'lib/aldous/controller_action.rb', line 46 def preconditions [] end |
#view_builder ⇒ Object
54 55 56 |
# File 'lib/aldous/controller_action.rb', line 54 def view_builder @view_builder ||= Aldous::ViewBuilder.new(controller.view_context, default_view_data) end |