Module: ParamsReady::Builder::GroupingLike
- Defined in:
- lib/params_ready/query/grouping.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, **opts, &proc) ⇒ Object
15
16
17
18
19
20
21
22
23
|
# File 'lib/params_ready/query/grouping.rb', line 15
def method_missing(name, *args, **opts, &proc)
builder_class = predicate_builder(name)
if builder_class
builder = builder_class.instance *args, **opts
build_predicate builder, &proc
else
super
end
end
|
Instance Method Details
#add_predicate(name_or_definition, *args, **opts, &block) ⇒ Object
37
38
39
40
41
42
43
44
45
|
# File 'lib/params_ready/query/grouping.rb', line 37
def add_predicate(name_or_definition, *args, **opts, &block)
if name_or_definition.is_a? Parameter::AbstractDefinition
@definition.add_predicate name_or_definition
add name_or_definition
else
builder = predicate_builder(name_or_definition).instance *args, **opts
build_predicate builder, &block
end
end
|
#build_predicate(builder, &proc) ⇒ Object
31
32
33
34
35
|
# File 'lib/params_ready/query/grouping.rb', line 31
def build_predicate(builder, &proc)
builder.instance_eval(&proc)
definition = builder.build
add_predicate definition
end
|
#operator(&block) ⇒ Object
47
48
49
50
|
# File 'lib/params_ready/query/grouping.rb', line 47
def operator(&block)
definition = Builder.define_grouping_operator(:operator, altn: :op, &block)
add definition
end
|
#predicate_builder(name) ⇒ Object
8
9
10
11
12
13
|
# File 'lib/params_ready/query/grouping.rb', line 8
def predicate_builder(name)
symbol = name.to_sym
return nil unless Query::PredicateRegistry.has_predicate?(symbol)
Query::PredicateRegistry.predicate(symbol)
end
|
#respond_to_missing?(name, include_private = false) ⇒ Boolean
25
26
27
28
29
|
# File 'lib/params_ready/query/grouping.rb', line 25
def respond_to_missing?(name, include_private = false)
return true unless predicate_builder(name).nil?
super
end
|
#to_query?(&block) ⇒ Boolean
52
53
54
|
# File 'lib/params_ready/query/grouping.rb', line 52
def to_query?(&block)
helper :to_query?, &block
end
|