Class: Refine::Conditions::BooleanCondition
Constant Summary
collapse
- CLAUSE_TRUE =
Clauses::TRUE
- CLAUSE_FALSE =
Clauses::FALSE
- CLAUSE_SET =
Clauses::SET
- CLAUSE_NOT_SET =
Clauses::NOT_SET
- I18N_PREFIX =
"refine.refine_blueprints.boolean_condition."
SupportsFlatQueries::LEFT_JOIN_CLAUSES
Instance Attribute Summary
Attributes inherited from Condition
#attribute, #before_validations, #clause, #display, #ensurances, #filter, #id, #is_flat_query, #is_refinement
Instance Method Summary
collapse
Methods included from HasClauses
#before_clause_validation, #boot_has_clauses, #clause_display_map, #custom_clauses, #ensure_clause, #ensure_clauses, #get_clause_by_id, #get_clauses, included, #only_clauses, #remap_clause_displays, #update_show_clauses, #with_clauses, #without_clauses
Methods inherited from Condition
#add_ensurance, #add_messages, #add_rules, #apply, #approved_clauses, #before_validate, #boot_traits, #call_proc_if_callable, #clause_display, #clause_exists?, #clause_in_approved_list?, #ensure_attribute_configured, #ensure_id, #evaluated_meta, #initialize, #messages, #recursively_evaluate_lazy_enumerable, #run_before_validate_validations, #run_ensurance_validations, #set_filter, #set_input_parameters, #to_array, #update_value, #validate_user_input, #with_display
#add_pending_join, #add_pending_joins_if_needed, #apply_flat, #apply_flat_relational_condition, #condition_uses_different_database?, #get_foreign_key_from_relation, #get_through_reflection, #handle_flat_cross_database_condition, #handle_flat_relational_condition
Methods included from HasIcon
#category_icon_class, #category_icon_template, #has_icon?, #icon_class, #icon_container_class, #icon_template, #with_category_icon_class, #with_category_icon_template, #with_icon, #with_icon_class, #with_icon_container_class, #with_icon_template
#forced_index, #with_forced_index
#through_id_relationship, #with_through_id_relationship
#apply_count_refinement, #apply_date_refinement, #apply_refinements, #define_count_condition, #define_date_condition, #get_count_refinement_condition, #get_date_refinement_condition, #has_any_refinements?, #has_count_refinement?, #has_date_refinement?, #refine_by_count, #refine_by_date, #refine_by_filter, #refinements_allowed?, #refinements_to_array
#apply_relationship_attribute, #can_use_where_in_relationship_subquery?, #create_pending_has_many_through_subquery, #create_pending_wherein_subquery, #get_reflection_object, #group, #is_relationship_attribute?, #key_1, #key_2, #raw_attribute, #should_inverse_clause?, #with_attribute
Methods included from HasMeta
#meta, #with_meta
Instance Method Details
#apply_clause_bool(table, bool) ⇒ Object
100
101
102
103
104
105
106
|
# File 'app/models/refine/conditions/boolean_condition.rb', line 100
def apply_clause_bool(table, bool)
if @nulls_are == bool
table.grouping(table[:"#{attribute}"].eq(bool).or(table[:"#{attribute}"].eq(nil)))
else
table.grouping(table[:"#{attribute}"].eq(bool))
end
end
|
#apply_clause_false(table) ⇒ Object
108
109
110
|
# File 'app/models/refine/conditions/boolean_condition.rb', line 108
def apply_clause_false(table)
apply_clause_bool(table, false)
end
|
#apply_clause_not_set(table) ⇒ Object
92
93
94
|
# File 'app/models/refine/conditions/boolean_condition.rb', line 92
def apply_clause_not_set(table)
table.grouping(table[:"#{attribute}"].eq(nil))
end
|
#apply_clause_set(table) ⇒ Object
88
89
90
|
# File 'app/models/refine/conditions/boolean_condition.rb', line 88
def apply_clause_set(table)
table.grouping(table[:"#{attribute}"].not_eq(nil))
end
|
#apply_clause_true(table) ⇒ Object
96
97
98
|
# File 'app/models/refine/conditions/boolean_condition.rb', line 96
def apply_clause_true(table)
apply_clause_bool(table, true)
end
|
#apply_condition(_input, table, _inverse_clause) ⇒ Object
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
# File 'app/models/refine/conditions/boolean_condition.rb', line 70
def apply_condition(_input, table, _inverse_clause)
case clause
when CLAUSE_SET
apply_clause_set(table)
when CLAUSE_NOT_SET
apply_clause_not_set(table)
when CLAUSE_TRUE
apply_clause_true(table)
when CLAUSE_FALSE
apply_clause_false(table)
end
end
|
#boot ⇒ Object
25
26
27
28
|
# File 'app/models/refine/conditions/boolean_condition.rb', line 25
def boot
@nulls_are = nil
hide_unknowns
end
|
#component ⇒ Object
12
13
14
|
# File 'app/models/refine/conditions/boolean_condition.rb', line 12
def component
"boolean-condition"
end
|
#hide_unknowns ⇒ Object
30
31
32
33
34
35
36
|
# File 'app/models/refine/conditions/boolean_condition.rb', line 30
def hide_unknowns
without_clauses([
CLAUSE_SET,
CLAUSE_NOT_SET,
])
self
end
|
#human_readable(input) ⇒ Object
16
17
18
19
20
21
22
23
|
# File 'app/models/refine/conditions/boolean_condition.rb', line 16
def human_readable(input)
current_clause = get_clause_by_id(input[:clause])
if input[:value]
"#{display} #{current_clause.display} #{input[:value]}"
else
"#{display} #{current_clause.display}"
end
end
|
#nulls_are_false ⇒ Object
43
44
45
46
|
# File 'app/models/refine/conditions/boolean_condition.rb', line 43
def nulls_are_false
@nulls_are = false
self
end
|
#nulls_are_true ⇒ Object
38
39
40
41
|
# File 'app/models/refine/conditions/boolean_condition.rb', line 38
def nulls_are_true
@nulls_are = true
self
end
|
#nulls_are_unknown ⇒ Object
48
49
50
51
|
# File 'app/models/refine/conditions/boolean_condition.rb', line 48
def nulls_are_unknown
@nulls_are = nil
self
end
|
#show_unknowns ⇒ Object
53
54
55
56
57
58
59
|
# File 'app/models/refine/conditions/boolean_condition.rb', line 53
def show_unknowns
with_clauses([
CLAUSE_SET,
CLAUSE_NOT_SET
])
self
end
|