Method: JSONAPI::Resource.apply_filter

Defined in:
lib/jsonapi/resource.rb

.apply_filter(records, filter, value, options = {}) ⇒ Object



673
674
675
676
677
678
679
680
681
682
683
684
685
# File 'lib/jsonapi/resource.rb', line 673

def apply_filter(records, filter, value, options = {})
  strategy = _allowed_filters.fetch(filter.to_sym, Hash.new)[:apply]

  if strategy
    if strategy.is_a?(Symbol) || strategy.is_a?(String)
      send(strategy, records, value, options)
    else
      strategy.call(records, value, options)
    end
  else
    records.where(filter => value)
  end
end