Class: Graphiti::FilterOperators::Catchall

Inherits:
Object
  • Object
show all
Defined in:
lib/graphiti/filter_operators.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &blk) ⇒ Object



20
21
22
# File 'lib/graphiti/filter_operators.rb', line 20

def method_missing(name, *args, &blk)
  @procs[name] = blk
end

Instance Attribute Details

#procsObject (readonly)

Returns the value of attribute procs.



4
5
6
# File 'lib/graphiti/filter_operators.rb', line 4

def procs
  @procs
end

Instance Method Details

#respond_to_missing?(*args) ⇒ Boolean

rubocop: enable Style/MethodMissingSuper

Returns:

  • (Boolean)


25
26
27
# File 'lib/graphiti/filter_operators.rb', line 25

def respond_to_missing?(*args)
  true
end

#to_hashObject



29
30
31
# File 'lib/graphiti/filter_operators.rb', line 29

def to_hash
  @procs
end