serverkit 0.6.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1dc4224d3244676e5064fef59a56e66af7a98977
4
- data.tar.gz: 9f2a56ff1bf509cf3433ef8319fb9c3265a09c93
3
+ metadata.gz: 40403ed3991e3dae313836b16ffe5ad523e9e924
4
+ data.tar.gz: 4520aaaff4ab249b9835f0a86cdd9356a629dfe6
5
5
  SHA512:
6
- metadata.gz: d98cd01c2f026fc9dd3214ac63ffc32730ee573948bef25928cec4f7bde700fe767597d30a4c417f7218960cf7553601899f41ae6f59af89cf6f2f9e0ac68cbe
7
- data.tar.gz: 9a456405ccc42069c96bc74ff9d86f7762f021ef61ec3c3aea0bfb2cf82d56a31f959ca9b29a1b05fbbe52e25f7eecb990532cd6adfaf9c18afa5e4b3565d893
6
+ metadata.gz: 9d3e9191d02228ea58997d78de98362e1e5da3aebc41cc1617e77088336db9753684886e973768d1b363dccc8112a80eb07f6940cf2cb2c5822fab0d8a149db1
7
+ data.tar.gz: 8524cc26214791599b074d18d98e19c06da654b9c90c32c7575009cfc64eb25a53f3936f0d797f4f489d538a04bd5e0c0feb7900fe243390de0a7b46340b2212
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 0.6.2
2
+ - Add AtLeastOneOfValidator
3
+
1
4
  ## 0.6.1
2
5
  - Move to home directory if user attribute is specified
3
6
 
@@ -0,0 +1,12 @@
1
+ require "active_model"
2
+ require "active_support/core_ext/array/conversions"
3
+ require "active_support/core_ext/object/try"
4
+
5
+ class AtLeastOneOfValidator < ActiveModel::EachValidator
6
+ def validate_each(record, attribute, value)
7
+ attributes = options[:in] + [attribute]
8
+ if attributes.all? { |name| record.try(name).nil? }
9
+ record.errors.add(attribute, "is required because at least one of #{attributes.to_sentence} are required")
10
+ end
11
+ end
12
+ end
@@ -1,6 +1,7 @@
1
1
  require "active_model"
2
2
  require "active_model/errors"
3
3
  require "active_support/core_ext/module/delegation"
4
+ require "at_least_one_of_validator"
4
5
  require "readable_validator"
5
6
  require "regexp_validator"
6
7
  require "required_validator"
@@ -1,3 +1,3 @@
1
1
  module Serverkit
2
- VERSION = "0.6.1"
2
+ VERSION = "0.6.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: serverkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-10 00:00:00.000000000 Z
11
+ date: 2015-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -240,6 +240,7 @@ files:
240
240
  - images/server-colored.png
241
241
  - images/server-small.png
242
242
  - images/server.png
243
+ - lib/at_least_one_of_validator.rb
243
244
  - lib/readable_validator.rb
244
245
  - lib/regexp_validator.rb
245
246
  - lib/required_validator.rb