Class: Wallaby::AbstractResponder
- Inherits:
-
ActionController::Responder
- Object
- ActionController::Responder
- Wallaby::AbstractResponder
- Includes:
- Responders::FlashResponder
- Defined in:
- lib/responders/wallaby/abstract_responder.rb
Overview
Abstract responder
Direct Known Subclasses
Instance Method Summary collapse
-
#to_csv ⇒ String
CSV.
-
#to_html ⇒ String
HTML.
-
#to_json ⇒ String
JSON.
Instance Method Details
#to_csv ⇒ String
Returns CSV.
19 20 21 22 23 |
# File 'lib/responders/wallaby/abstract_responder.rb', line 19 def to_csv set_layout_to_none headers['Content-Disposition'] = "attachment; filename=\"#{file_name}\"" default_render end |
#to_html ⇒ String
Returns HTML.
9 10 11 12 13 14 15 16 |
# File 'lib/responders/wallaby/abstract_responder.rb', line 9 def to_html if post? then create_action elsif patch? || put? then update_action elsif delete? then destroy_action else default_render end end |
#to_json ⇒ String
Returns JSON.
26 27 28 29 30 31 32 33 |
# File 'lib/responders/wallaby/abstract_responder.rb', line 26 def to_json set_layout_to_none return default_render unless post? || patch? || put? || delete? if has_errors? then \ render :bad_request, .merge(status: :bad_request) else render :form, end end |