valle 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +1 -1
- data/Rakefile +0 -1
- data/lib/valle/hooks.rb +17 -14
- data/valle.gemspec +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: 5ca0aea17b7da5744740b3dfcf3455854bb014a9
|
4
|
+
data.tar.gz: 0e78df15afcdfd34a21c93a98e96468c67664e5c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bca7bae0f542cf6f28b4c9c286f2b03747d02fcb09331f303c078d829afc92dca237a1ad422e0ea5366cf86cf9b1d5a6656d0842a28e74e237b9b08df6475b03
|
7
|
+
data.tar.gz: 42e8c838dfbc2e782424d68eff7527c406faa0b7ff6df3fda4350e9abe31a068f318c69416d0e4783083c9ec9bc128d790d24ae326243f553f95861708b80d30
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Valle [![Build Status](https://
|
1
|
+
# Valle [![Build Status](https://travis-ci.org/akalyaev/valle.svg?branch=master)](https://travis-ci.org/akalyaev/valle) [![Code Climate](https://codeclimate.com/github/akalyaev/valle/badges/gpa.svg)](https://codeclimate.com/github/akalyaev/valle) [![Gem Version](https://badge.fury.io/rb/valle.svg)](https://badge.fury.io/rb/valle)
|
2
2
|
|
3
3
|
Valle automatically creates validations for the minimum and maximum values of fields in your ActiveRecord model(s). No more worrying that string lengths or ID values will exceed the permissible DB limits!
|
4
4
|
|
data/Rakefile
CHANGED
data/lib/valle/hooks.rb
CHANGED
@@ -1,4 +1,17 @@
|
|
1
1
|
module Valle
|
2
|
+
|
3
|
+
##
|
4
|
+
# Extends the ActiveRecord's inherited method
|
5
|
+
#
|
6
|
+
module ActiveRecordExt
|
7
|
+
def inherited(subclass)
|
8
|
+
super
|
9
|
+
if Valle::Hooks.can_add_validators?(subclass, self)
|
10
|
+
Valle::Hooks.add_validators(subclass)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
2
15
|
class Hooks
|
3
16
|
|
4
17
|
class << self
|
@@ -8,25 +21,15 @@ module Valle
|
|
8
21
|
#
|
9
22
|
def init
|
10
23
|
ActiveSupport.on_load(:active_record) do
|
11
|
-
Valle::Hooks.
|
24
|
+
Valle::Hooks.run if Valle.enabled?
|
12
25
|
end
|
13
26
|
end
|
14
27
|
|
15
28
|
##
|
16
|
-
#
|
29
|
+
# Runs all the hooks, required for this gem
|
17
30
|
#
|
18
|
-
def
|
19
|
-
ActiveRecord::Base.
|
20
|
-
class << self
|
21
|
-
def inherited_with_valle_validators(subclass)
|
22
|
-
inherited_without_valle_validators(subclass)
|
23
|
-
if Valle::Hooks.can_add_validators?(subclass, self)
|
24
|
-
Valle::Hooks.add_validators(subclass)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
alias_method_chain :inherited, :valle_validators
|
28
|
-
end
|
29
|
-
end
|
31
|
+
def run
|
32
|
+
ActiveRecord::Base.singleton_class.include(Valle::ActiveRecordExt)
|
30
33
|
end
|
31
34
|
|
32
35
|
##
|
data/valle.gemspec
CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |gem|
|
|
13
13
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
14
|
gem.name = "valle"
|
15
15
|
gem.require_paths = ["lib"]
|
16
|
-
gem.version = "1.1.
|
16
|
+
gem.version = "1.1.1"
|
17
17
|
|
18
18
|
gem.add_dependency 'activerecord', '>= 3.0'
|
19
19
|
gem.add_dependency 'activesupport'
|
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: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton Kalyaev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|