Module: Railsful::Interceptors::Include
- Included in:
- Serializer
- Defined in:
- lib/railsful/interceptors/include.rb
Overview
This interceptors implements the “include” functionality for a given record or a relation.
Instance Method Summary collapse
- #include_options(options) ⇒ Object
-
#includes ⇒ Array
Fetch the list of all includes.
- #render(options) ⇒ Object
-
#should_include? ⇒ Boolean
Check if options should contain includes.
Instance Method Details
#include_options(options) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/railsful/interceptors/include.rb', line 12 def () # Check if include key should be merged into options hash. return unless should_include? # Deep merge include options, so we do not override existing # include options. .deeper_merge(include: includes) end |
#includes ⇒ Array
Fetch the list of all includes.
33 34 35 |
# File 'lib/railsful/interceptors/include.rb', line 33 def includes params.fetch(:include, nil).to_s.split(',') end |
#render(options) ⇒ Object
8 9 10 |
# File 'lib/railsful/interceptors/include.rb', line 8 def render() super(()) end |
#should_include? ⇒ Boolean
Check if options should contain includes.
24 25 26 27 28 |
# File 'lib/railsful/interceptors/include.rb', line 24 def should_include? # Only GET requests should have the "include" functionality, # since it may be a parameter in a create or update action. method == 'GET' && includes.any? end |