Method: Chewy::Search::Parameters::Source#render

Defined in:
lib/chewy/search/parameters/source.rb

#render{Symbol => Object}?

Renders false if source is disabled, otherwise renders the contents of includes value or even the entire hash if excludes also specified.

Returns:

  • ({Symbol => Object}, nil)

    rendered value with the parameter name

See Also:



49
50
51
52
53
54
55
56
57
# File 'lib/chewy/search/parameters/source.rb', line 49

def render
  if !value[:enabled]
    {self.class.param_name => false}
  elsif value[:excludes].present?
    {self.class.param_name => value.slice(:includes, :excludes).reject { |_, v| v.blank? }}
  elsif value[:includes].present?
    {self.class.param_name => value[:includes]}
  end
end