dynabute 0.0.9 → 0.0.10
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 +4 -4
- data/lib/dynabute/field.rb +4 -0
- data/lib/dynabute/values/base.rb +9 -0
- data/lib/dynabute/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 855927fb2405931b0b4e9d9ef9964e31edbc4472
|
4
|
+
data.tar.gz: 9ffdf3c1530dc7fdb4006b7e9637b32a6ceef5f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d6a71ac578927b9149d7f87dc7e6e63e3bc9b19ea7b2599c740b0e87ce1cbe880c6cf4c8d0f6c204d09dcfb7126f97e839cc90d21dffa230b581f5ea473f8623
|
7
|
+
data.tar.gz: 3f52ff46aea08dcce1fc6b8434f690d318edfe89c969d5331e94eb04591d24dcde5d0ca8e704ac0e8b31484f9739cfc70a8e3b9fece3f4e2c9cda7f454b2b251
|
data/lib/dynabute/field.rb
CHANGED
data/lib/dynabute/values/base.rb
CHANGED
@@ -11,10 +11,19 @@ module Dynabute::Values
|
|
11
11
|
validate Dynabute::Util.nested_attributable_presence_validator(:field_id, :field)
|
12
12
|
validate Dynabute::Util.nested_attributable_presence_validator(:dynabutable_id, :dynabutable)
|
13
13
|
validate Dynabute::Util.nested_attributable_presence_validator(:dynabutable_type, :dynabutable)
|
14
|
+
before_create :reject_duplication_for_has_one
|
14
15
|
|
15
16
|
def value_type
|
16
17
|
field.value_type
|
17
18
|
end
|
19
|
+
|
20
|
+
private
|
21
|
+
def reject_duplication_for_has_one
|
22
|
+
return if field.has_many
|
23
|
+
return unless self.class.exists?(field_id: field_id, dynabutable_id: dynabutable_id, dynabutable_type: dynabutable_type)
|
24
|
+
self.errors[:base] << 'Multiple records for has_one relationship detected'
|
25
|
+
throw :abort
|
26
|
+
end
|
18
27
|
end
|
19
28
|
|
20
29
|
end
|
data/lib/dynabute/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dynabute
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Liooo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|