Class: Abc::BaseConductor
- Inherits:
-
Object
- Object
- Abc::BaseConductor
- Defined in:
- lib/abc/base_conductor.rb
Overview
The Base Conductor is the conductor that all other conductors inherit from. Its primary role is to decipher the parameters, retrieve or save data to or from data-facing APIs like a database or a third-party API, and to optionally wrap what it plans to return in an object that provides methods for access (in some cases, abstracting complex logic away from the view).
The Conductor is not responsible, however, for validating or wrapping the data it retrieves. That task is delegated down to the application.
Class Method Summary collapse
-
.call(params, options = {}) ⇒ Hash
Runs the conductor and returns a hash of objects (presenter or otherwise) that are passed to the view.
Instance Method Summary collapse
-
#to_response ⇒ Hash
Transforms the data returned by the #data method into an acceptable format to return to the controller.
Class Method Details
.call(params, options = {}) ⇒ Hash
Runs the conductor and returns a hash of objects (presenter or otherwise) that are passed to the view.
20 21 22 |
# File 'lib/abc/base_conductor.rb', line 20 def call(params, = {}) new(params, ).to_response end |
Instance Method Details
#to_response ⇒ Hash
Transforms the data returned by the #data method into an acceptable format to return to the controller. Primarily used to wrap data in presenters, but can pass entities back, too.
30 31 32 |
# File 'lib/abc/base_conductor.rb', line 30 def to_response raise ResponseNotSpecifiedError, "#to_response must be overridden when subclassing BaseConductor" end |