Sha256: 43751b25e50ef25e20ffd15eda0f8d41b1bd35e712f1a4c79b462518f22285f3

Contents?: true

Size: 770 Bytes

Versions: 1

Compression:

Stored size: 770 Bytes

Contents

module JsonapiCompliable
  # @api private
  module Scoping::Filterable
    # @api private
    def find_filter(name)
      find_filter!(name)
    rescue JsonapiCompliable::Errors::AttributeError
      nil
    end

    # @api private
    def find_filter!(name)
      resource.class.get_attr!(name, :filterable, request: true)
      { name => resource.filters[name] }
    end

    # @api private
    def filter_param
      query_hash[:filter] || {}
    end

    def missing_required_filters
      required_attributes - filter_param.keys
    end

    def required_attributes
      resource.attributes.map do |k, v|
        k if v[:filterable] == :required
      end.compact
    end

    def required_filters_provided?
      missing_required_filters.empty?
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jsonapi_compliable-1.0.alpha.2 lib/jsonapi_compliable/scoping/filterable.rb