active_warnings 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -8
- data/lib/active_warnings.rb +1 -2
- data/lib/active_warnings/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ef4b6ee4ee25e15dd0b7ed506c8b6ac94bb5486
|
4
|
+
data.tar.gz: d43cf2e0ea7c0fa868a882818015aab03d0fd9fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38c4ed1ef15f88ea32346533529a93b34ffb7cf848f6d8e44268e3f47d66e07a618390221fb18e36ae3af877bf49b767f115ee156b9ed7f181e68115c705a043
|
7
|
+
data.tar.gz: e472e787b804bd2b9932ec0b06e59c513101c34daa0a975bc832f4263adc03b84875168391f4b344bc03a44ba4b4f2dd15e792a2ddfc339ebba61be2a7d98136
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# ActiveWarnings [![Build Status](https://travis-ci.org/s12chung/active_warnings.svg?branch=test_active_model)](https://travis-ci.org/s12chung/active_warnings)
|
2
2
|
|
3
|
-
`ActiveModel::Validations`
|
3
|
+
Separate `ActiveModel::Validations` errors for warnings.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -27,12 +27,11 @@ class BasicModel
|
|
27
27
|
attr_accessor :name
|
28
28
|
def initialize(name); @name = name; end
|
29
29
|
|
30
|
-
validates :name, presence: true
|
31
|
-
|
32
30
|
warnings do
|
33
|
-
# to share the same validators, error related methods now correspond to warnings. ie:
|
34
|
-
# the method #valid? == #safe? and #errors == #warnings
|
35
31
|
validates :name, absence: true
|
32
|
+
|
33
|
+
# Example custom validation
|
34
|
+
validate { errors.add(:name, "is some_name") if name == "some_name" }
|
36
35
|
end
|
37
36
|
end
|
38
37
|
|
@@ -40,14 +39,19 @@ end
|
|
40
39
|
# Basic Use
|
41
40
|
#
|
42
41
|
model = BasicModel.new("some_name")
|
43
|
-
model.valid? # => true
|
44
|
-
model.errors.keys # => []
|
45
42
|
|
43
|
+
# Regular ActiveModel::Validations errors work separately
|
44
|
+
model.valid? # => true
|
45
|
+
model.errors.full_messages # => []
|
46
|
+
|
47
|
+
# like `#valid?`
|
46
48
|
model.safe? # => false
|
47
49
|
model.no_warnings? # => false, equivalent to #safe?
|
50
|
+
# like `#invalid?`
|
48
51
|
model.unsafe? # => true
|
49
52
|
model.has_warnings? # => true, equivalent to #unsafe?
|
50
|
-
|
53
|
+
# like `#errors`
|
54
|
+
model.warnings.full_messages # => ["Name must be blank", "Name is some_name"]
|
51
55
|
|
52
56
|
#
|
53
57
|
# Advanced Use
|
data/lib/active_warnings.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_warnings
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve Chung
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -64,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
64
64
|
version: '0'
|
65
65
|
requirements: []
|
66
66
|
rubyforge_project:
|
67
|
-
rubygems_version: 2.
|
67
|
+
rubygems_version: 2.5.1
|
68
68
|
signing_key:
|
69
69
|
specification_version: 4
|
70
70
|
summary: Separate ActiveModel::Validations for warnings.
|