Class: Graphiti::FilterOperators::Catchall
- Defined in:
- lib/graphiti/filter_operators.rb
Instance Attribute Summary collapse
-
#procs ⇒ Object
readonly
Returns the value of attribute procs.
Instance Method Summary collapse
-
#initialize(resource, type_name, opts) ⇒ Catchall
constructor
A new instance of Catchall.
- #method_missing(name, *args, &blk) ⇒ Object
-
#respond_to_missing?(*args) ⇒ Boolean
rubocop: enable Style/MethodMissingSuper.
- #to_hash ⇒ Object
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
#procs ⇒ Object (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
25 26 27 |
# File 'lib/graphiti/filter_operators.rb', line 25 def respond_to_missing?(*args) true end |
#to_hash ⇒ Object
29 30 31 |
# File 'lib/graphiti/filter_operators.rb', line 29 def to_hash @procs end |