Module: HalApi::Representer::Embeds::HalApiRailsRenderPipeline
- Defined in:
- lib/hal_api/representer/embeds.rb
Instance Method Summary collapse
- #embed_zoomed?(name, zoom_def = nil, zoom_param = nil) ⇒ Boolean
- #render_functions ⇒ Object
- #skip_property?(binding, private_options) ⇒ Boolean
-
#suppress_embed?(input, options) ⇒ Boolean
embed if zoomed.
Instance Method Details
#embed_zoomed?(name, zoom_def = nil, zoom_param = nil) ⇒ Boolean
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/hal_api/representer/embeds.rb', line 54 def (name, zoom_def = nil, zoom_param = nil) # if the embed in the representer definition has `zoom: :always` defined # always embed it, even if it is in another embed # (this is really meant for collections where embedded items must be included) return true if zoom_def == :always # passing nil explicitly overwrites defaults in signature, # so we default to nil and fix in the method body zoom_def = true if zoom_def.nil? # if there is no zoom specified in the request params (options) # then embed based on the zoom option in the representer definition # if there is a zoom specified in the request params (options) # then do not zoom when this name is not in the request zoom_param.nil? ? zoom_def : zoom_param.include?(name) end |
#render_functions ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/hal_api/representer/embeds.rb', line 28 def render_functions funcs = super f = ->(input, ) do if (input, ) return Representable::Pipeline::Stop end end [f] + funcs end |
#skip_property?(binding, private_options) ⇒ Boolean
24 25 26 |
# File 'lib/hal_api/representer/embeds.rb', line 24 def skip_property?(binding, ) super(binding, ) || (binding, ) end |
#suppress_embed?(input, options) ⇒ Boolean
embed if zoomed
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/hal_api/representer/embeds.rb', line 39 def (input, ) = [:options] binding = [:binding] name = binding.evaluate_option(:as, input, ) = binding[:embedded] return false if ! ## check if it should be zoomed, suppress if not !(name, binding[:zoom], [:zoom]) end |