Class: CanCanCan::ActiveGraph::CypherConstructorHelper
- Inherits:
-
Object
- Object
- CanCanCan::ActiveGraph::CypherConstructorHelper
- Defined in:
- lib/cancancan/active_graph/cypher_constructor_helper.rb
Overview
Cypher query constructs
Class Method Summary collapse
- .path_end_var(relationship, conditions) ⇒ Object
- .path_node(target_class, var_label) ⇒ Object
- .var_name(class_constant) ⇒ Object
- .variable_in_path?(relationship, conditions) ⇒ Boolean
Class Method Details
.path_end_var(relationship, conditions) ⇒ Object
25 26 27 28 29 |
# File 'lib/cancancan/active_graph/cypher_constructor_helper.rb', line 25 def path_end_var(relationship, conditions) with_var = variable_in_path?(relationship, conditions) target_class = relationship.target_class with_var ? var_name(target_class) : '' end |
.path_node(target_class, var_label) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/cancancan/active_graph/cypher_constructor_helper.rb', line 10 def path_node(target_class, var_label) label = target_class.mapped_label_names .map { |label_name| ":`#{label_name}`" } .join "(#{var_label}#{label})" end |
.var_name(class_constant) ⇒ Object
6 7 8 |
# File 'lib/cancancan/active_graph/cypher_constructor_helper.rb', line 6 def var_name(class_constant) class_constant.name.downcase.split('::').join('_') end |
.variable_in_path?(relationship, conditions) ⇒ Boolean
17 18 19 20 21 22 23 |
# File 'lib/cancancan/active_graph/cypher_constructor_helper.rb', line 17 def variable_in_path?(relationship, conditions) boolean = [TrueClass, FalseClass].include?(conditions.class) return false if conditions.blank? || boolean !relationship.target_class .associations[conditions.keys.first] .present? end |