Module: Graphiti::Scoping::Filterable Private

Included in:
DefaultFilter, Filter
Defined in:
lib/graphiti/scoping/filterable.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Instance Method Details

#dependent_filtersObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



45
46
47
48
49
# File 'lib/graphiti/scoping/filterable.rb', line 45

def dependent_filters
  resource.filters.select do |k, v|
    v[:dependencies].present?
  end
end

#filter_paramObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



18
19
20
# File 'lib/graphiti/scoping/filterable.rb', line 18

def filter_param
  query_hash[:filter] || {}
end

#find_filter(name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



5
6
7
8
9
# File 'lib/graphiti/scoping/filterable.rb', line 5

def find_filter(name)
  find_filter!(name)
rescue Graphiti::Errors::AttributeError
  nil
end

#find_filter!(name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



12
13
14
15
# File 'lib/graphiti/scoping/filterable.rb', line 12

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

#missing_dependent_filtersObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/graphiti/scoping/filterable.rb', line 32

def missing_dependent_filters
  [].tap do |arr|
    filter_param.each_pair do |key, value|
      if (df = dependent_filters[key])
        missing = df[:dependencies] - filter_param.keys
        unless missing.length.zero?
          arr << {filter: df, missing: missing}
        end
      end
    end
  end
end

#missing_required_filtersObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



22
23
24
# File 'lib/graphiti/scoping/filterable.rb', line 22

def missing_required_filters
  required_filters - filter_param.keys
end

#required_filtersObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



26
27
28
29
30
# File 'lib/graphiti/scoping/filterable.rb', line 26

def required_filters
  resource.filters.map { |k, v|
    k if v[:required]
  }.compact
end