ph_model 1.1.0 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +9 -0
- data/README.md +1 -0
- data/lib/active_model/validations/type_validator.rb +1 -1
- data/lib/ph_model/concerns/attribute_nested_validation.rb +7 -2
- data/lib/ph_model/concerns/attribute_type_validation.rb +2 -2
- data/lib/ph_model/version.rb +1 -1
- data/lib/ph_model.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b21ee085fad1255502d03a29da7c57d01cbea98465169b750643ad41544170fe
|
4
|
+
data.tar.gz: b558977aa8e7620fb580b5861f7706b8af7019363debc34c6465b7236f11f750
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e381cc246de657326afcb31e75b8a6dd7e48f1dfde51b8645b66d9efee197381838c996ffebd89884e57447e496116153fa1679b885488e89784862d65193c9e
|
7
|
+
data.tar.gz: 2c86ce6deccccf5e63332c9e3c6387d7195254cc6b8e02a7220d8a7462a53f13c9adae2c9c6dc30baa70e0d1a133d64c96fb98ca65a99c9d14d5b7b4a18449e6
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## [v1.1.0](https://github.com/payrollhero/ph_model/tree/v1.1.0) (2017-05-23)
|
4
|
+
[Full Changelog](https://github.com/payrollhero/ph_model/compare/v1.0.2...v1.1.0)
|
5
|
+
|
6
|
+
## [v1.0.2](https://github.com/payrollhero/ph_model/tree/v1.0.2) (2017-04-06)
|
7
|
+
[Full Changelog](https://github.com/payrollhero/ph_model/compare/v1.0.1...v1.0.2)
|
8
|
+
|
9
|
+
## [v1.0.1](https://github.com/payrollhero/ph_model/tree/v1.0.1) (2017-04-04)
|
10
|
+
[Full Changelog](https://github.com/payrollhero/ph_model/compare/v1.0.0...v1.0.1)
|
11
|
+
|
3
12
|
## [v1.0.0](https://github.com/payrollhero/ph_model/tree/v1.0.0) (2017-04-04)
|
4
13
|
[Full Changelog](https://github.com/payrollhero/ph_model/compare/v0.0.1...v1.0.0)
|
5
14
|
|
data/README.md
CHANGED
@@ -11,6 +11,7 @@
|
|
11
11
|
[![Code Climate](https://codeclimate.com/github/payrollhero/ph_model/badges/gpa.svg)](https://codeclimate.com/github/payrollhero/ph_model)
|
12
12
|
[![Issue Count](https://codeclimate.com/github/payrollhero/ph_model/badges/issue_count.svg)](https://codeclimate.com/github/payrollhero/ph_model)
|
13
13
|
[![Dependency Status](https://gemnasium.com/payrollhero/ph_model.svg)](https://gemnasium.com/payrollhero/ph_model)
|
14
|
+
[![Gem Version](https://badge.fury.io/rb/ph_model.svg)](https://badge.fury.io/rb/ph_model)
|
14
15
|
|
15
16
|
This Gem basically marries ActiveModel and ActiveAttr is a nice package.
|
16
17
|
|
@@ -18,7 +18,7 @@ module ActiveModel
|
|
18
18
|
allowed_classes = classes.to_sentence two_words_connector: " or ",
|
19
19
|
last_word_connector: ", or "
|
20
20
|
|
21
|
-
record.errors
|
21
|
+
record.errors.add(attribute, (options[:message] || "must be a #{allowed_classes}"))
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
@@ -13,7 +13,7 @@ module PhModel
|
|
13
13
|
if info[:type].is_a? Array
|
14
14
|
if value.respond_to? :each_with_index
|
15
15
|
value.each_with_index do |item_value, index|
|
16
|
-
check_one(item_value,
|
16
|
+
check_one(item_value, format_nested_attribute_name(attribute_name, index, item_value))
|
17
17
|
end
|
18
18
|
end
|
19
19
|
else
|
@@ -22,8 +22,13 @@ module PhModel
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
+
def format_nested_attribute_name(attribute_name, index, item_value)
|
26
|
+
"#{attribute_name}[#{index}]"
|
27
|
+
end
|
28
|
+
|
25
29
|
def check_one(value, attribute_name)
|
26
|
-
return if !value.respond_to?(:valid?) || !value.respond_to?(:errors) || value.errors.nil? ||
|
30
|
+
return if !value.respond_to?(:valid?) || !value.respond_to?(:errors) || value.errors.nil? ||
|
31
|
+
(value.respond_to?(:frozen?) && value.frozen?) || value.valid?
|
27
32
|
value.errors.full_messages.each do |message|
|
28
33
|
errors.add(:base, "#{attribute_name}.#{message}")
|
29
34
|
end
|
@@ -40,8 +40,8 @@ module PhModel
|
|
40
40
|
when nil
|
41
41
|
true
|
42
42
|
when Array
|
43
|
-
if type.count
|
44
|
-
|
43
|
+
if type.count > 1
|
44
|
+
type.any? { |typ| value.is_a?(typ) }
|
45
45
|
else
|
46
46
|
if value.kind_of? Array
|
47
47
|
value.all? { |item| item.is_a?(type.first) }
|
data/lib/ph_model/version.rb
CHANGED
data/lib/ph_model.rb
CHANGED
@@ -31,7 +31,7 @@ module PhModel
|
|
31
31
|
include Concerns::AttributeNestedValidation
|
32
32
|
include Concerns::AttributeOfArrayTypeInitialization
|
33
33
|
|
34
|
-
def as_json
|
34
|
+
def as_json(*)
|
35
35
|
{}.tap do |hash|
|
36
36
|
self.class.attributes.each do |attribute_name, _info|
|
37
37
|
hash[attribute_name] = send(attribute_name).as_json
|
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.1.
|
4
|
+
version: 1.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Banasik
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -231,8 +231,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
231
231
|
- !ruby/object:Gem::Version
|
232
232
|
version: '0'
|
233
233
|
requirements: []
|
234
|
-
|
235
|
-
rubygems_version: 2.5.2
|
234
|
+
rubygems_version: 3.2.32
|
236
235
|
signing_key:
|
237
236
|
specification_version: 4
|
238
237
|
summary: ph-model -- active_model, active_attr brought together at last
|