Class: Mongory::Matchers::Registry
- Inherits:
-
Struct
- Object
- Struct
- Mongory::Matchers::Registry
- Defined in:
- lib/mongory/matchers.rb
Overview
Internal helper representing a registration of an operator and its associated symbol snippet method. Used to delay method definition on Symbol until explicitly enabled.
Each instance holds:
- the method symbol (e.g.,
:gt
) - the corresponding Mongo-style operator (e.g.,
"$gt"
)
These instances are collected and replayed upon calling Matchers.enable_symbol_snippets!
.
Instance Attribute Summary collapse
-
#method_sym ⇒ Symbol
The symbol method name (e.g., :in, :gt, :exists).
-
#operator ⇒ String
The Mongo-style operator this snippet maps to (e.g., "$in").
Instance Method Summary collapse
-
#apply! ⇒ void
Defines a method on Symbol to support operator snippet expansion.
Instance Attribute Details
#method_sym ⇒ Symbol
Returns the symbol method name (e.g., :in, :gt, :exists).
138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/mongory/matchers.rb', line 138 Registry = Struct.new(:method_sym, :operator) do # Defines a method on Symbol to support operator snippet expansion. # # @return [void] def apply! return if Symbol.method_defined?(method_sym) operator = operator() Symbol.define_method(method_sym) do Mongory::QueryOperator.new(to_s, operator) end end end |
#operator ⇒ String
Returns the Mongo-style operator this snippet maps to (e.g., "$in").
138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/mongory/matchers.rb', line 138 Registry = Struct.new(:method_sym, :operator) do # Defines a method on Symbol to support operator snippet expansion. # # @return [void] def apply! return if Symbol.method_defined?(method_sym) operator = operator() Symbol.define_method(method_sym) do Mongory::QueryOperator.new(to_s, operator) end end end |
Instance Method Details
#apply! ⇒ void
This method returns an undefined value.
Defines a method on Symbol to support operator snippet expansion.
142 143 144 145 146 147 148 149 |
# File 'lib/mongory/matchers.rb', line 142 def apply! return if Symbol.method_defined?(method_sym) operator = operator() Symbol.define_method(method_sym) do Mongory::QueryOperator.new(to_s, operator) end end |