cancancan-neo4j 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8e08a1d2366ed56a2098252068703e1038e44527
4
- data.tar.gz: c83757e84d871344219d64e8d6739ac124091bc1
3
+ metadata.gz: f5213aae2b6c9b1dced0d36464e2ae1c458f9fc9
4
+ data.tar.gz: dcddcb66fef4186dc1a8ac08c4e11619982d645a
5
5
  SHA512:
6
- metadata.gz: 9d6d307fca81de261d85d3c0590e791520398dfd54f624edfffd56d8d3e5bd79e3b688fdfe6cb3dbdcaa4d35ba840caefcfd153877f58e83b7cd6197c2ef3781
7
- data.tar.gz: cffd3d0cde2bf8999ce78fbdba0e179e35c989944a3d6da035fffde35b6ab393ad2f133410d4cadf5e65336e53c6fe2a45c24101ffc9c6197080847a3b819d06
6
+ metadata.gz: '008f34d8928100cb0d40cd291f30567238007cdf3a3358766d6f2990244caf6bb76e9296ac35a5989f0a09830923c94e67d5dfb6e9f3a4e0e304cb4dcfb9c725'
7
+ data.tar.gz: 1a7a2ceff81a4038556862cff6281a05987286732395c4792701b53c23b2c8fb0452aa185d7d2635a8ee5d0b326077b773897108763dbccf61e6d0dc76a41571
@@ -41,9 +41,8 @@ module CanCanCan
41
41
  model_attr_exists = model_conditions.any? do |key, _|
42
42
  !target_class.associations_keys.include?(key)
43
43
  end
44
- end_node = model_attr_exists ? CypherConstructorHelper.match_node_cypher(target_class) : '()'
45
- arrow_cypher = relationship.arrow_cypher(nil, {}, false, false, rel_length)
46
- current_path = @options[:path] + arrow_cypher + end_node
44
+ to_node = CypherConstructorHelper.match_node_cypher(target_class) if model_attr_exists
45
+ current_path = path_with_relationship(relationship, rel_length, to_node)
47
46
  if model_attr_exists
48
47
  append_matches(relationship)
49
48
  append_and_to_conditions_string
@@ -68,9 +67,10 @@ module CanCanCan
68
67
  @conditions_string += con_string
69
68
  end
70
69
 
71
- def path_with_relationship(relationship, rel_length)
70
+ def path_with_relationship(relationship, rel_length, to_node = nil)
72
71
  arrow_cypher = relationship.arrow_cypher(nil, {}, false, false, rel_length)
73
- @options[:path] + arrow_cypher + '()'
72
+ to_node_label = CypherConstructorHelper.path_end_node(relationship)
73
+ @options[:path] + arrow_cypher + (to_node || to_node_label)
74
74
  end
75
75
  end
76
76
  end
@@ -35,7 +35,8 @@ module CanCanCan
35
35
 
36
36
  def condtion_for_path(path:, variable_name:, base_class:, key:)
37
37
  path = "(#{variable_name})" if path.blank?
38
- path + base_class.associations[key].arrow_cypher + '()'
38
+ relationship = base_class.associations[key]
39
+ path + relationship.arrow_cypher + path_end_node(relationship)
39
40
  end
40
41
 
41
42
  def condition_for_id(base_class, variable_name, value)
@@ -65,6 +66,10 @@ module CanCanCan
65
66
  connector += 'NOT' if rule_cypher.append_not_to_conditions?
66
67
  cypher_options[:conditions] = conditions_string + connector
67
68
  end
69
+
70
+ def path_end_node(relationship)
71
+ '(' + relationship.target_class.mapped_label_names.map { |label_name| ":`#{label_name}`" }.join + ')'
72
+ end
68
73
  end
69
74
  end
70
75
  end
@@ -2,6 +2,6 @@ module CanCanCan
2
2
  end
3
3
  module CanCanCan
4
4
  module Neo4j
5
- VERSION = '1.2.1'.freeze
5
+ VERSION = '1.2.2'.freeze
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cancancan-neo4j
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Amit Suryavanshi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-27 00:00:00.000000000 Z
11
+ date: 2018-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement