activegraph 11.1.0.alpha.2 → 11.1.0.alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 711b583f7886a76627f5b3f696e38de523bfefb0309eaed03c0b05c3667ad0b6
|
4
|
+
data.tar.gz: 0daad52238037ba7b78fd4fca0c98cecf81d4b9b48b8af8505bfd28def03c7f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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 =
|
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
|
-
|
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
|
data/lib/active_graph/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2022-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|