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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cf514cc9b79f38e7ee4b7d7caeb9a13abf294f47
4
- data.tar.gz: fb3630e3ff30d01fff6a43d1f8916ecb5cca1578
3
+ metadata.gz: 74380cfc7d5d671f280d9b6debdcf816c9764257
4
+ data.tar.gz: aa0ed5f2056665c3a42744efd3514440111ac98e
5
5
  SHA512:
6
- metadata.gz: a0a37000da3fe826b10496dc335ad14d0e6a97bde094616f86da813e4449e621449dd4be98afaf29a9be4ba2cc401dde6b7b3d9138c1200c8bf263bad52449e8
7
- data.tar.gz: fc6909f682a8a68513eb3a8fda035d57ffc7a9449d41ef878b79ef98c57d0ddd8baccd9246e7c81026e0dc691820434e6602fdec47a69becc8fbb8430ce05bda
6
+ metadata.gz: e4a60d882046ba792eba8b368589ce09cd29fb12f3cc6898a8ba6065bcc078c69632e591a213ed372e2f9a2b3654cf0cf51ff2db957a97563dcfb772ee7ad4cd
7
+ data.tar.gz: 62cd4431afe7e8967751bc1daf8abbbc133c9864ecbb9312e0b458bab870909600c3e5adef52d17f4e2cdb2495c22d96e22aa80bee2eb7f259942002852a9713
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.2.2 / 2013-11-28
2
+
3
+ * fix relation does not exist error (fixes #10) [qblake]
4
+
1
5
  ## 0.2.1 / 2013-11-27
2
6
 
3
7
  * fixed uninitialized constant AR::SchemaMigration [Anton Kalyaev]
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 (Valle.can_process_model?(subclass.model_name) &&
24
- self == ActiveRecord::Base &&
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
- # Extends the functionality of ActiveRecord::Validations valid? method
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 extend_ar_validations_valid_method(subclass)
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
@@ -1,3 +1,3 @@
1
1
  module Valle
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
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.1
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-27 00:00:00.000000000 Z
11
+ date: 2013-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord