run_cl 1.6.1 → 1.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2e3b5b5d31c686d2f2305c1f8b9a61293a2556cd
4
- data.tar.gz: 1ea8bf1cd14fed138d328f7d8635c7ae1008faf2
3
+ metadata.gz: 6a17e5a29daeca5dfdc021df36397c9999a472d8
4
+ data.tar.gz: 4e71f0fc8392d0e8d9ba3a274d0bed4947533756
5
5
  SHA512:
6
- metadata.gz: 9c82515760af5e3fac6457fb427496884f6b4512b2f3b2e42db55c05f2edfc426c8b0f28101730b67d841e5f64a16068b9d58b6a91c5e5856291ac0d97c38ff5
7
- data.tar.gz: e7674d0e90a6461407af2f22ee81ff67867667912f9c8cca68046fb06a3c259493ae7ccf737db145d72065c6675b3039ba08a30bbe298249cb4d284395836af7
6
+ metadata.gz: 91a7f3ac29364d5259cd66d8abfd81f1ecf8fdb29de0f748365fd536073a55f58e6d12b9f18d40477d682c6f7c8bf95980abcdc4e2a1e1398e7a2802af9359e0
7
+ data.tar.gz: 819802be60bf82ccdb50325b2cc120e3b72e16a87f5a0a8d455fb3a09689f3174ecb3670ad3f82798098474f2f75969f277fa51f4679f19c97d345667d97fcb7
@@ -1,13 +1,10 @@
1
1
  # encoding: utf-8
2
2
 
3
- class RunValidator < ActiveModel::Validator
4
- def validate record
5
- options[:attributes].each do |attribute|
6
- record.errors[attribute.to_sym] << 'no es válido' unless Run.valid?(record.send(attribute))
7
- end
3
+ class RunValidator < ActiveModel::EachValidator
4
+ def validate_each(record, attribute, value)
5
+ record.errors[attribute] << (options[:message] || 'no es válido') unless Run.valid?(value)
8
6
  end
9
7
 
10
- private
11
8
  # TODO - locales
12
9
  # record.errors[attribute.to_sym] << I18n.t('run.invalid') unless Run.valid? record.send(attribute)
13
- end
10
+ end
@@ -1,28 +1,23 @@
1
1
  # encoding: utf-8
2
2
 
3
- class UniqRunValidator < ActiveModel::Validator
4
- def validate record
5
- options[:attributes].each do |attribute|
6
- run = Run.remove_format record.send(attribute)
3
+ class UniqRunValidator < ActiveModel::EachValidator
4
+ def validate_each(record, attribute, value)
5
+ run = Run.remove_format value
7
6
 
8
- matchers = []
9
- if record.new_record?
10
- matchers = record.class.where(attribute => run)
11
- else
12
- matchers = record.class.where('? = ? AND id != ?', attribute, run, record.id)
13
- end
14
-
15
- if options[:scope]
16
- matchers = matchers.where(options[:scope] => record.send(options[:scope]))
17
- end
18
-
19
- matchers.any?
7
+ matchers = []
8
+ if record.new_record?
9
+ matchers = record.class.where(attribute => run)
10
+ else
11
+ matchers = record.class.where('? = ? AND id != ?', attribute, run, record.id)
12
+ end
20
13
 
21
- record.errors[attribute.to_sym] << 'ya está en uso!!!' if matchers.any?
14
+ if options[:scope]
15
+ matchers = matchers.where(options[:scope] => record.send(options[:scope]))
22
16
  end
17
+
18
+ record.errors[attribute.to_sym] << (options[:message] || 'ya está en uso') if matchers.any?
23
19
  end
24
20
 
25
- private
26
21
  # TODO - locales
27
22
  # record.errors[attribute.to_sym] << I18n.t('run.in_use') unless Run.valid? record.send(attribute)
28
23
  end
@@ -1,3 +1,3 @@
1
1
  module RunCl
2
- VERSION = "1.6.1"
2
+ VERSION = "1.6.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: run_cl
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.1
4
+ version: 1.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - mespina
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-02 00:00:00.000000000 Z
11
+ date: 2016-07-01 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Formateador/Desformateador, Generador, Validador de Rut Chilenos
14
14
  email: