activemodel-behavior_validator 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/behavior_validator.rb +2 -4
- data/lib/behavior_validator/version.rb +1 -1
- data/spec/behavior_validator_spec.rb +3 -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: 95e39de4761601fc6a4688f2ddf20e88d79a81e2
|
4
|
+
data.tar.gz: 5a542853207a721590e3d116cb7f0a0fe5f8711c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 027580b1fb8ad37c0c588c5181705c215ed2f9d332369c31a5e8003b1546277b756058edd449779901742a034b9f98f122af08ee8ba4b042dc60a6f5a9d93181
|
7
|
+
data.tar.gz: 7e63c4d455cfdd03a8b6971e48322681597aa5ca89f7c5bc3e428fc1e31c36c152832bbf327d890bb6c033b85ac6174251db69791356fd93e7b9d7c9ecf8b890
|
data/lib/behavior_validator.rb
CHANGED
@@ -3,14 +3,12 @@ class BehaviorValidator < ActiveModel::EachValidator
|
|
3
3
|
def valid?(value, options = {})
|
4
4
|
options = options.reject { |option| reserved_options.include?(option) }
|
5
5
|
options.each_pair.all? do |method, expected_result|
|
6
|
-
value.__send__(method) == expected_result
|
6
|
+
value.respond_do?(method) && value.__send__(method) == expected_result
|
7
7
|
end
|
8
|
-
rescue NoMethodError
|
9
|
-
false
|
10
8
|
end
|
11
9
|
|
12
10
|
def reserved_options
|
13
|
-
[:allow_nil, :allow_blank, :message, :on]
|
11
|
+
[:allow_nil, :allow_blank, :message, :on, :if, :unless]
|
14
12
|
end
|
15
13
|
end
|
16
14
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activemodel-behavior_validator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuku Takahashi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|