ph_model 1.0.2 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ph_model/concerns/attribute_type_validation.rb +7 -1
- data/lib/ph_model/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: 45d4629bdc212f29675b3b25d5c86fb28688af9a
|
4
|
+
data.tar.gz: 9cf7cbc3e9903b1c84ea2bc0b4de7e68edb71647
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5301189e640e50e16f1910f8d8b824b45439c6c221c6f4a0d9358cf18b1f744db8c1d4ae9ccb0a1a29142e49a2b70383bcfbf1f9be5a353d91aae481d38b7a0e
|
7
|
+
data.tar.gz: c3e8f29ce56c2663900ec45d9a0ffae810b41df4d53b174796d1eb847e5b07898931b591ba06ccfaa38a66588e6e9f1eae9982acbd8f07888c45883bf705d3a8
|
@@ -1,5 +1,11 @@
|
|
1
1
|
module PhModel
|
2
2
|
module Concerns
|
3
|
+
|
4
|
+
# This will validate any attribute defined with `type: `
|
5
|
+
# the type value should be a class, or the special notation `[SomeClass]` which is meant to designate that this is
|
6
|
+
# a collection of those classes
|
7
|
+
#
|
8
|
+
# `no_type_check: true` can be optionally passed to disable this check (other features might use the `type` column)
|
3
9
|
module AttributeTypeValidation
|
4
10
|
extend ActiveSupport::Concern
|
5
11
|
|
@@ -9,7 +15,7 @@ module PhModel
|
|
9
15
|
|
10
16
|
def ensure_typed_attributes_class
|
11
17
|
self.class.attributes.each do |attribute_name, info|
|
12
|
-
if info[:type] && !type_match?(attribute_name)
|
18
|
+
if info[:type] && !info[:no_type_check] && !type_match?(attribute_name)
|
13
19
|
errors.add(attribute_name, "must be #{info[:type].inspect}, was #{type_summary(attribute_name)}")
|
14
20
|
end
|
15
21
|
end
|
data/lib/ph_model/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ph_model
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Banasik
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|