Sha256: c90b733ae459d36a45189bd58159beb65cac1988fa01020382c957170fd198f5

Contents?: true

Size: 711 Bytes

Versions: 39

Compression:

Stored size: 711 Bytes

Contents

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

    # @api private
    def find_filter!(name)
      filter_name, filter_value = \
        resource.filters.find { |_name, opts| opts[:aliases].include?(name.to_sym) }
      raise JsonapiCompliable::Errors::BadFilter unless filter_name
      if guard = filter_value[:if]
        raise JsonapiCompliable::Errors::BadFilter if resource.context.send(guard) == false
      end
      { filter_name => filter_value }
    end

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

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
jsonapi_compliable-0.11.13 lib/jsonapi_compliable/scoping/filterable.rb
jsonapi_compliable-0.11.12 lib/jsonapi_compliable/scoping/filterable.rb
jsonapi_compliable-0.11.11 lib/jsonapi_compliable/scoping/filterable.rb
jsonapi_compliable-0.11.10 lib/jsonapi_compliable/scoping/filterable.rb
jsonapi_compliable-0.11.8 lib/jsonapi_compliable/scoping/filterable.rb
jsonapi_compliable-0.11.7 lib/jsonapi_compliable/scoping/filterable.rb
jsonapi_compliable-0.11.6 lib/jsonapi_compliable/scoping/filterable.rb
jsonapi_compliable-0.11.5 lib/jsonapi_compliable/scoping/filterable.rb
jsonapi_compliable-0.11.4 lib/jsonapi_compliable/scoping/filterable.rb
jsonapi_compliable-0.11.3 lib/jsonapi_compliable/scoping/filterable.rb
jsonapi_compliable-0.11.2 lib/jsonapi_compliable/scoping/filterable.rb
jsonapi_compliable-0.11.1 lib/jsonapi_compliable/scoping/filterable.rb
jsonapi_compliable-0.11.0 lib/jsonapi_compliable/scoping/filterable.rb
jsonapi_compliable-0.10.9 lib/jsonapi_compliable/scoping/filterable.rb
jsonapi_compliable-0.10.7 lib/jsonapi_compliable/scoping/filterable.rb
jsonapi_compliable-0.10.6 lib/jsonapi_compliable/scoping/filterable.rb
jsonapi_compliable-0.10.5 lib/jsonapi_compliable/scoping/filterable.rb
jsonapi_compliable-0.10.4 lib/jsonapi_compliable/scoping/filterable.rb
jsonapi_compliable-0.10.3 lib/jsonapi_compliable/scoping/filterable.rb
jsonapi_compliable-0.10.2 lib/jsonapi_compliable/scoping/filterable.rb