input_sanitizer 0.1.9 → 0.1.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -78,4 +78,14 @@ module InputSanitizer
78
78
  end
79
79
  end
80
80
  end
81
+
82
+ module AllowNil
83
+ def call(value)
84
+ if value.nil? || value == ""
85
+ nil
86
+ else
87
+ super(value)
88
+ end
89
+ end
90
+ end
81
91
  end
@@ -1,14 +1,4 @@
1
1
  module InputSanitizer
2
- module AllowNil
3
- def call(value)
4
- if value.nil? || value == ""
5
- nil
6
- else
7
- super(value)
8
- end
9
- end
10
- end
11
-
12
2
  class PositiveIntegerConverter < IntegerConverter
13
3
  def call(value)
14
4
  val = super
@@ -57,24 +57,12 @@ class InputSanitizer::Sanitizer
57
57
  subclass.fields = self.fields.dup
58
58
  end
59
59
 
60
- def self.string(*keys)
61
- set_keys_to_type(keys, :string)
62
- end
63
-
64
- def self.integer(*keys)
65
- set_keys_to_type(keys, :integer)
66
- end
67
-
68
- def self.boolean(*keys)
69
- set_keys_to_type(keys, :boolean)
70
- end
71
-
72
- def self.date(*keys)
73
- set_keys_to_type(keys, :date)
74
- end
75
-
76
- def self.time(*keys)
77
- set_keys_to_type(keys, :time)
60
+ converters.keys.each do |name|
61
+ class_eval <<-END
62
+ def self.#{name}(*keys)
63
+ set_keys_to_type(keys, :#{name})
64
+ end
65
+ END
78
66
  end
79
67
 
80
68
  def self.custom(*keys)
@@ -1,3 +1,3 @@
1
1
  module InputSanitizer
2
- VERSION = "0.1.9"
2
+ VERSION = "0.1.10"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: input_sanitizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: