Class: Transit::Controller::Responder
- Inherits:
-
ActionController::Responder
- Object
- ActionController::Responder
- Transit::Controller::Responder
- Includes:
- Responders::FlashResponder
- Defined in:
- lib/transit/controller/responder.rb
Constant Summary collapse
- @@flash_keys =
[ :success, :error ]
Instance Method Summary collapse
-
#initialize(controller, resources, options = {}) ⇒ Responder
constructor
A new instance of Responder.
- #to_js ⇒ Object
Constructor Details
#initialize(controller, resources, options = {}) ⇒ Responder
Returns a new instance of Responder.
14 15 16 17 18 19 20 |
# File 'lib/transit/controller/responder.rb', line 14 def initialize(controller, resources, ={}) super @flash = .delete(:flash) @notice = .delete(:success) @alert = .delete(:error) @flash_now = .delete(:flash_now) end |
Instance Method Details
#to_js ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/transit/controller/responder.rb', line 22 def to_js if header_hash = {} controller.flash.each{ |key, value| header_hash.merge!(key => value) } controller.response['X-Flash-Messages'] = header_hash.to_json end defined?(super) ? super : to_format end |