activegraph 11.1.0.alpha.2 → 11.1.0.alpha.3

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
  SHA256:
3
- metadata.gz: 9cea5056d3980b49a22a7b7fce375b776f58f420e1612b1b5d5578e56b20dcc4
4
- data.tar.gz: 66361ac53d3d004201ee95c3ac5ee8810435bc16fc81ba281e19b3a3969cc945
3
+ metadata.gz: 711b583f7886a76627f5b3f696e38de523bfefb0309eaed03c0b05c3667ad0b6
4
+ data.tar.gz: 0daad52238037ba7b78fd4fca0c98cecf81d4b9b48b8af8505bfd28def03c7f4
5
5
  SHA512:
6
- metadata.gz: 1ac6ed636cf918c6112b4e60b7f4cb1ffca0c42b2c14f9e63082130a19598be099536fc10c71ae92122e5b6c900b5f9c865305bcf7a0beacd3128144a85a904d
7
- data.tar.gz: 3555cf27ff1990c870e257e15c0cb6d42a38741029aebc787f30cabc14f08d8487ce3701fe3e1e55ed55731f06237cfe55dbdb2f09243a6967d392f9c9147c7a
6
+ metadata.gz: 9a456ac9a035520694c24d68e58e687208237dabfd185f57d845ec36a8caee1ade2f03cabc3cfb8a9dae1dff6dcbec2645b757a2b2935d88de2594a0f0ff7ba3
7
+ data.tar.gz: 9ce3325eafd3f5edffa5b0931039748e652150e0a403312eddbfd9a7321af5bbce72f3c31ae7e11588e6f2890ec3045abd5fba38bdc515ed36dcc505eb92e71c
@@ -5,7 +5,6 @@ module ActiveGraph
5
5
  extend ActiveSupport::Concern
6
6
  include ActiveGraph::Shared::Validations
7
7
 
8
-
9
8
  # @return [Boolean] true if valid
10
9
  def valid?(context = nil)
11
10
  context ||= (new_record? ? :create : :update)
@@ -19,7 +18,6 @@ module ActiveGraph
19
18
  end
20
19
  end
21
20
 
22
-
23
21
  class UniquenessValidator < ::ActiveModel::EachValidator
24
22
  def initialize(options)
25
23
  super(options.reverse_merge(case_sensitive: true))
@@ -32,14 +30,19 @@ module ActiveGraph
32
30
  end
33
31
 
34
32
  def found(record, attribute, value)
35
- conditions = scope_conditions(record)
33
+ scopes, attributes = Array(options[:scope] || []).partition { |s| s.is_a?(Proc) }
34
+ conditions = scope_conditions(record, attributes)
36
35
 
37
36
  # TODO: Added as find(:name => nil) throws error
38
37
  value = '' if value.nil?
39
38
 
40
39
  conditions[attribute] = options[:case_sensitive] ? value : /#{Regexp.escape(value.to_s)}/i
41
40
 
42
- found = record.class.as(:result).where(conditions)
41
+ found = if scopes.empty?
42
+ record.class.as(:result)
43
+ else
44
+ scopes.reduce(record) { |proxy, scope| proxy.instance_eval(&scope) }
45
+ end.where(conditions)
43
46
  found = found.where_not(neo_id: record.neo_id) if record._persisted_obj
44
47
  found
45
48
  end
@@ -48,8 +51,8 @@ module ActiveGraph
48
51
  super || 'has already been taken'
49
52
  end
50
53
 
51
- def scope_conditions(instance)
52
- Array(options[:scope] || []).inject({}) do |conditions, key|
54
+ def scope_conditions(instance, attributes)
55
+ attributes.inject({}) do |conditions, key|
53
56
  conditions.merge(key => instance[key])
54
57
  end
55
58
  end
@@ -91,6 +91,9 @@ COMMENT
91
91
 
92
92
  ActiveGraph::Base.transaction do
93
93
  runner = ActiveGraph::Migrations::Runner.new
94
+ end
95
+
96
+ ActiveGraph::Base.transaction do
94
97
  runner.mark_versions_as_complete(schema_data[:versions]) # Run in test mode?
95
98
  end
96
99
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveGraph
2
- VERSION = '11.1.0.alpha.2'
2
+ VERSION = '11.1.0.alpha.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activegraph
3
3
  version: !ruby/object:Gem::Version
4
- version: 11.1.0.alpha.2
4
+ version: 11.1.0.alpha.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andreas Ronge, Brian Underwood, Chris Grigg, Heinrich Klobuczek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-11 00:00:00.000000000 Z
11
+ date: 2022-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel