standalone_validator 0.2.0 → 0.2.1

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: 5240e1091aa1fd4290b125cb6d22cf2a3cd33c2b
4
- data.tar.gz: fdf9ef36aedb36bc40cfdcf614e0c404294c0f8e
3
+ metadata.gz: ee76a41270f159a0fa58356c11739379f388b937
4
+ data.tar.gz: f482deae225caae5f396ff7995b808472e170573
5
5
  SHA512:
6
- metadata.gz: f9dfd502615a818b236e367367d4ac8102848bf7e0ed13c8c37c41b1c000ce7030b40299007c9c94a389744a446bef026cfbbc9bb86000476db0edab063cf645
7
- data.tar.gz: e212f3ce900f2b2ed9abece568defc32fa05bb3ef88178be2bfe025dd32f56c24174f6da6067c00c06fd202a79a7353673c90df344e9fcd99c33956c2f1e5f30
6
+ metadata.gz: 8f9183664c27a3bf6cfb812d8a47ebf5f2b15d83e548974b7e77e0ae1b899c0e13550b74f815fd1506276a998c3fb05b689ed1ecb15dd2e4d532f73b145b3aa9
7
+ data.tar.gz: 52ace947a6ff30a932c9c25e3db10be2d4625ad7280fa05f21cda29f9727e37faf35208d8c89c4b2264fd19332e9fa7089c7f224c7bcafa3021db4b933cbd17d
@@ -9,14 +9,18 @@ class StandaloneValidator
9
9
  end
10
10
  end
11
11
 
12
- ALWAYS_TRUE = Proc.new { true }
12
+ ALWAYS_TRUE = ->(*) { true }.freeze
13
13
 
14
14
  def self.condition_for(options)
15
15
  if options.has_key?(:if)
16
16
  options[:if].to_proc
17
17
  elsif options.has_key?(:unless)
18
18
  reverse_condition = options[:unless].to_proc
19
- Proc.new { |*args| not reverse_condition.call(*args) }
19
+
20
+ ->(*args) {
21
+ negates = instance_exec(*args, &reverse_condition)
22
+ not negates
23
+ }
20
24
  else
21
25
  ALWAYS_TRUE
22
26
  end
@@ -29,7 +33,7 @@ class StandaloneValidator
29
33
  module ClassMethods
30
34
  def include_validation(&block)
31
35
  super do |object, result|
32
- if condition.call(object)
36
+ if instance_exec(object, &condition)
33
37
  instance_exec(object, result, &block)
34
38
  end
35
39
  end
@@ -1,3 +1,3 @@
1
1
  class StandaloneValidator
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: standalone_validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Renato Zannon