Module: Caprese::Rendering
- Extended by:
- ActiveSupport::Concern
- Included in:
- Controller
- Defined in:
- lib/caprese/controller/concerns/rendering.rb
Instance Method Summary collapse
-
#meta ⇒ Hash
Allows for meta tags to be added in response document.
-
#render(options = {}) ⇒ Object
Override render so we can automatically use our adapter and find the appropriate serializer instead of requiring that they be explicity stated.
Instance Method Details
#meta ⇒ Hash
Allows for meta tags to be added in response document
40 41 42 |
# File 'lib/caprese/controller/concerns/rendering.rb', line 40 def ||= {} end |
#render(options = {}) ⇒ Object
Override render so we can automatically use our adapter and find the appropriate serializer instead of requiring that they be explicity stated
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/caprese/controller/concerns/rendering.rb', line 11 def render( = {}) if .is_a?(Hash) && [:json] [:adapter] = Caprese::Adapter::JsonApi [:meta] = unless .empty? if [:json].respond_to?(:to_ary) if [:json].first.is_a?(Error) [:each_serializer] ||= Serializer::ErrorSerializer elsif [:json].any? [:each_serializer] ||= serializer_for([:json].first) end else if [:json].is_a?(Error) [:serializer] ||= Serializer::ErrorSerializer elsif [:json].present? [:serializer] ||= serializer_for([:json]) end end end super end |