carrierwave-size-validator 0.0.1 → 0.1.0

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.
@@ -29,8 +29,8 @@ module ActiveModel
29
29
  keys.each do |key|
30
30
  value = options[key]
31
31
 
32
- unless value.is_a?(Integer) && value >= 0
33
- raise ArgumentError, ":#{key} must be a nonnegative Integer"
32
+ unless (value.is_a?(Integer) && value >= 0) || value.is_a?(Proc)
33
+ raise ArgumentError, ":#{key} must be a nonnegative Integer or Proc"
34
34
  end
35
35
  end
36
36
  end
@@ -47,6 +47,8 @@ module ActiveModel
47
47
  CHECKS.each do |key, validity_check|
48
48
  next unless check_value = options[key]
49
49
 
50
+ check_value = check_value.call(record) if check_value.is_a?(Proc)
51
+
50
52
  value ||= [] if key == :maximum
51
53
 
52
54
  value_size = value.size
@@ -1,7 +1,7 @@
1
1
  module Carrierwave
2
2
  module Size
3
3
  module Validator
4
- VERSION = "0.0.1"
4
+ VERSION = "0.1.0"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carrierwave-size-validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-04 00:00:00.000000000 Z
12
+ date: 2013-04-30 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Gemified file size validator based on https://gist.github.com/chrisbloom7/1009861
15
15
  email: