valle 0.2.1 → 0.2.2
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/CHANGELOG.md +4 -0
- data/lib/valle/hooks.rb +18 -7
- data/lib/valle/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: 74380cfc7d5d671f280d9b6debdcf816c9764257
|
4
|
+
data.tar.gz: aa0ed5f2056665c3a42744efd3514440111ac98e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4a60d882046ba792eba8b368589ce09cd29fb12f3cc6898a8ba6065bcc078c69632e591a213ed372e2f9a2b3654cf0cf51ff2db957a97563dcfb772ee7ad4cd
|
7
|
+
data.tar.gz: 62cd4431afe7e8967751bc1daf8abbbc133c9864ecbb9312e0b458bab870909600c3e5adef52d17f4e2cdb2495c22d96e22aa80bee2eb7f259942002852a9713
|
data/CHANGELOG.md
CHANGED
data/lib/valle/hooks.rb
CHANGED
@@ -20,27 +20,38 @@ module Valle
|
|
20
20
|
class << self
|
21
21
|
def inherited_with_valle_validators(subclass)
|
22
22
|
inherited_without_valle_validators(subclass)
|
23
|
-
if
|
24
|
-
|
25
|
-
(defined?(ActiveRecord::SchemaMigration) && subclass != ActiveRecord::SchemaMigration)) # skip AR::SchemaMigration (AR >= 4.X)
|
26
|
-
Valle::Hooks.extend_ar_validations_valid_method(subclass)
|
23
|
+
if Valle::Hooks.can_add_validators?(subclass, self)
|
24
|
+
Valle::Hooks.add_validators(subclass)
|
27
25
|
end
|
28
26
|
end
|
29
|
-
|
30
27
|
alias_method_chain :inherited, :valle_validators
|
31
28
|
end
|
32
29
|
end
|
33
30
|
end
|
34
31
|
|
35
32
|
##
|
36
|
-
#
|
33
|
+
# Adds validators to subclass
|
37
34
|
#
|
38
35
|
# @param [ActiveRecord::Base] subclass the AR::Base child class
|
39
36
|
# @note ActiveRecord::Validations should be defined at this point
|
40
37
|
#
|
41
|
-
def
|
38
|
+
def add_validators(subclass)
|
42
39
|
Valle::Manager.add_validators(subclass)
|
43
40
|
end
|
41
|
+
|
42
|
+
##
|
43
|
+
# Check whenether we should add validators to subclass
|
44
|
+
#
|
45
|
+
# @param [ActiveRecord::Base] subclass the AR::Base child class
|
46
|
+
# @param [ActiveRecord::Base] inherited_from_class the AR::Base parent class
|
47
|
+
# @note ActiveRecord::Validations should be defined at this point
|
48
|
+
#
|
49
|
+
def can_add_validators?(subclass, inherited_from_class)
|
50
|
+
Valle.can_process_model?(subclass.model_name) &&
|
51
|
+
inherited_from_class == ActiveRecord::Base &&
|
52
|
+
subclass.table_exists? &&
|
53
|
+
(defined?(ActiveRecord::SchemaMigration) && subclass != ActiveRecord::SchemaMigration) # skip AR::SchemaMigration (AR >= 4.X)
|
54
|
+
end
|
44
55
|
end
|
45
56
|
end
|
46
57
|
end
|
data/lib/valle/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: valle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton Kalyaev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11-
|
11
|
+
date: 2013-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|