Class: CanCanCan::Neo4j::RuleCypher

Inherits:
Object
  • Object
show all
Defined in:
lib/cancancan/neo4j/rule_cypher.rb

Overview

Constructs cypher conditions for rule and cypher match classes

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ RuleCypher

Returns a new instance of RuleCypher.



10
11
12
13
14
15
# File 'lib/cancancan/neo4j/rule_cypher.rb', line 10

def initialize(options)
  @options = options
  @rule_conditions = ''
  @cypher_matches = []
  construct_cypher_conditions
end

Instance Attribute Details

#cypher_matchesObject (readonly)

Returns the value of attribute cypher_matches.



8
9
10
# File 'lib/cancancan/neo4j/rule_cypher.rb', line 8

def cypher_matches
  @cypher_matches
end

#rule_conditionsObject (readonly)

Returns the value of attribute rule_conditions.



8
9
10
# File 'lib/cancancan/neo4j/rule_cypher.rb', line 8

def rule_conditions
  @rule_conditions
end

Instance Method Details

#append_not_to_conditions?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/cancancan/neo4j/rule_cypher.rb', line 29

def append_not_to_conditions?
  !rule_conditions_blank? && !@options[:rule].base_behavior
end

#conditions_connectorObject



25
26
27
# File 'lib/cancancan/neo4j/rule_cypher.rb', line 25

def conditions_connector
  @options[:rule].base_behavior ? ' OR ' : ' AND '
end

#construct_cypher_conditionsObject



17
18
19
20
21
22
23
# File 'lib/cancancan/neo4j/rule_cypher.rb', line 17

def construct_cypher_conditions
  if @options[:rule].conditions.blank?
    condition_for_rule_without_conditions
  else
    set_cypher_options
  end
end