Method: Graphiti::FilterOperators::Catchall#initialize

Defined in:
lib/graphiti/filter_operators.rb

#initialize(resource, type_name, opts) ⇒ Catchall

Returns a new instance of Catchall.



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/graphiti/filter_operators.rb', line 6

def initialize(resource, type_name, opts)
  @procs = {}
  defaults = resource.adapter.default_operators[type_name] || [:eq]
  if opts[:only]
    defaults = defaults.select { |op| Array(opts[:only]).include?(op) }
  end
  if opts[:except]
    defaults = defaults.reject { |op| Array(opts[:except]).include?(op) }
  end
  defaults.each do |op|
    @procs[op] = nil
  end
end