Class: EscortMission::Responder
- Inherits:
-
Object
- Object
- EscortMission::Responder
- Defined in:
- lib/escort_mission.rb
Overview
Uses the given escort’s controller to respond to the current request. This could involve rendering a conventional template or returning a serialized output of the model.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#controller ⇒ Object
readonly
Returns the value of attribute controller.
-
#escort ⇒ Object
readonly
Returns the value of attribute escort.
Instance Method Summary collapse
-
#display(records) ⇒ Object
Override this to provide controller-specific details for responding to the controller request in a certain way.
-
#initialize(escort) ⇒ Responder
constructor
A new instance of Responder.
-
#method_missing(method_name, *args) ⇒ Object
Passes the given method to the escort to fetch the records, and then calls #display to respond to the controller request.
Constructor Details
#initialize(escort) ⇒ Responder
Returns a new instance of Responder.
28 29 30 31 |
# File 'lib/escort_mission.rb', line 28 def initialize(escort) @escort = escort @controller = escort.controller end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args) ⇒ Object
Passes the given method to the escort to fetch the records, and then calls #display to respond to the controller request.
41 42 43 44 45 |
# File 'lib/escort_mission.rb', line 41 def method_missing(method_name, *args) records = @escort.send(method_name, *args) display(records) records end |
Instance Attribute Details
#controller ⇒ Object (readonly)
Returns the value of attribute controller.
26 27 28 |
# File 'lib/escort_mission.rb', line 26 def controller @controller end |
#escort ⇒ Object (readonly)
Returns the value of attribute escort.
26 27 28 |
# File 'lib/escort_mission.rb', line 26 def escort @escort end |
Instance Method Details
#display(records) ⇒ Object
Override this to provide controller-specific details for responding to the controller request in a certain way.
35 36 37 |
# File 'lib/escort_mission.rb', line 35 def display(records) raise NotImplementedError end |