stronger_parameters 2.6.0 → 2.6.1

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: 9cee9c15067d436594362c541eda36feab8727e6
4
- data.tar.gz: ff64518e518b16e4077a9539a056c4906bfbaf43
3
+ metadata.gz: bfaeb90bb2f1ba836eb17d917f923700f13f0954
4
+ data.tar.gz: 6be4921c1fc1d6343b767f8edd8d1789860c7d73
5
5
  SHA512:
6
- metadata.gz: 28f33d4429925ec7e889dfa42ccb7c8efc0c06d3a8d7da778c584f17483de9b3585e28c2d8ad3725a975fe7171e9ed457fb53c539a59f84520e337a6d93f25c2
7
- data.tar.gz: ce86345534a475a3030ceefffa52d0de28619373c7bc57f07c63666199c9814118a8e87470e62cdb2fc91c104d2849ef8f9ad73a4b2cfb41330d1d1d6ef769ad
6
+ metadata.gz: 6f608723da40c29edf0fe29294c80ec5eb1b4e79111e094ad7139afa1cf42789201d48bab9d1f5bb0f860fa4cccb517ee9760806ccc4d0b1acebe1046c0c63a7
7
+ data.tar.gz: 8eb47b550731ca07ae0b309fdc6cb66cc228c28cfa6d93300487e1ab6523eb56ad23bbeb4f399cf1f95afbca295b8976d7ca9e54c3af6446ba92398f19e5a438
@@ -0,0 +1,78 @@
1
+ require 'stronger_parameters/errors'
2
+
3
+ module StrongerParameters
4
+ class Constraint
5
+ def value(v)
6
+ v
7
+ end
8
+
9
+ def |(other)
10
+ OrConstraint.new(self, other)
11
+ end
12
+
13
+ def &(other)
14
+ AndConstraint.new(self, other)
15
+ end
16
+
17
+ def ==(other)
18
+ self.class == other.class
19
+ end
20
+ end
21
+
22
+ class OrConstraint < Constraint
23
+ attr_reader :constraints
24
+
25
+ def initialize(*constraints)
26
+ @constraints = constraints
27
+ end
28
+
29
+ def value(v)
30
+ exception = nil
31
+
32
+ constraints.each do |c|
33
+ result = c.value(v)
34
+ if result.is_a?(InvalidValue)
35
+ exception ||= result
36
+ else
37
+ return result
38
+ end
39
+ end
40
+
41
+ exception
42
+ end
43
+
44
+ def |(other)
45
+ constraints << other
46
+ self
47
+ end
48
+
49
+ def ==(other)
50
+ super && constraints == other.constraints
51
+ end
52
+ end
53
+
54
+ class AndConstraint < Constraint
55
+ attr_reader :constraints
56
+
57
+ def initialize(*constraints)
58
+ @constraints = constraints
59
+ end
60
+
61
+ def value(v)
62
+ constraints.each do |c|
63
+ v = c.value(v)
64
+ return v if v.is_a?(InvalidValue)
65
+ end
66
+ v
67
+ end
68
+
69
+ def &(other)
70
+ constraints << other
71
+ self
72
+ end
73
+
74
+ def ==(other)
75
+ super && constraints == other.constraints
76
+ end
77
+ end
78
+ end
@@ -1,4 +1,4 @@
1
- require 'stronger_parameters/constraints'
1
+ require 'stronger_parameters/constraint'
2
2
 
3
3
  module StrongerParameters
4
4
  class ArrayConstraint < Constraint
@@ -1,4 +1,4 @@
1
- require 'stronger_parameters/constraints'
1
+ require 'stronger_parameters/constraint'
2
2
 
3
3
  module StrongerParameters
4
4
  class BooleanConstraint < Constraint
@@ -1,4 +1,4 @@
1
- require 'stronger_parameters/constraints'
1
+ require 'stronger_parameters/constraint'
2
2
 
3
3
  module StrongerParameters
4
4
  class ComparisonConstraints < Constraint
@@ -1,4 +1,4 @@
1
- require 'stronger_parameters/constraints'
1
+ require 'stronger_parameters/constraint'
2
2
 
3
3
  module StrongerParameters
4
4
  class DateTimeConstraint < Constraint
@@ -1,4 +1,4 @@
1
- require 'stronger_parameters/constraints'
1
+ require 'stronger_parameters/constraint'
2
2
 
3
3
  module StrongerParameters
4
4
  class DecimalConstraint < Constraint
@@ -1,4 +1,4 @@
1
- require 'stronger_parameters/constraints'
1
+ require 'stronger_parameters/constraint'
2
2
 
3
3
  module StrongerParameters
4
4
  class EnumerationConstraint < Constraint
@@ -1,4 +1,4 @@
1
- require 'stronger_parameters/constraints'
1
+ require 'stronger_parameters/constraint'
2
2
 
3
3
  module StrongerParameters
4
4
  class FileConstraint < Constraint
@@ -1,4 +1,4 @@
1
- require 'stronger_parameters/constraints'
1
+ require 'stronger_parameters/constraint'
2
2
 
3
3
  module StrongerParameters
4
4
  class FloatConstraint < Constraint
@@ -1,4 +1,4 @@
1
- require 'stronger_parameters/constraints'
1
+ require 'stronger_parameters/constraint'
2
2
 
3
3
  module StrongerParameters
4
4
  class HashConstraint < Constraint
@@ -1,4 +1,4 @@
1
- require 'stronger_parameters/constraints'
1
+ require 'stronger_parameters/constraint'
2
2
 
3
3
  module StrongerParameters
4
4
  class HexConstraint < Constraint
@@ -1,9 +1,9 @@
1
- require 'stronger_parameters/constraints'
1
+ require 'stronger_parameters/constraint'
2
2
 
3
3
  module StrongerParameters
4
4
  class IntegerConstraint < Constraint
5
5
  def value(v)
6
- if v.is_a?(Fixnum) || v.is_a?(Bignum)
6
+ if v.is_a?(Integer)
7
7
  return v
8
8
  elsif v.is_a?(String) && v =~ /\A-?\d+\Z/
9
9
  return v.to_i
@@ -1,4 +1,4 @@
1
- require 'stronger_parameters/constraints'
1
+ require 'stronger_parameters/constraint'
2
2
 
3
3
  module StrongerParameters
4
4
  class NilConstraint < Constraint
@@ -1,4 +1,4 @@
1
- require 'stronger_parameters/constraints'
1
+ require 'stronger_parameters/constraint'
2
2
 
3
3
  module StrongerParameters
4
4
  class NilStringConstraint < Constraint
@@ -1,4 +1,4 @@
1
- require 'stronger_parameters/constraints'
1
+ require 'stronger_parameters/constraint'
2
2
 
3
3
  module StrongerParameters
4
4
  class RegexpConstraint < Constraint
@@ -1,4 +1,4 @@
1
- require 'stronger_parameters/constraints'
1
+ require 'stronger_parameters/constraint'
2
2
 
3
3
  module StrongerParameters
4
4
  class StringConstraint < Constraint
@@ -1,82 +1,4 @@
1
- require 'stronger_parameters/errors'
2
-
3
- module StrongerParameters
4
- class Constraint
5
- def value(v)
6
- v
7
- end
8
-
9
- def |(other)
10
- OrConstraint.new(self, other)
11
- end
12
-
13
- def &(other)
14
- AndConstraint.new(self, other)
15
- end
16
-
17
- def ==(other)
18
- self.class == other.class
19
- end
20
- end
21
-
22
- class OrConstraint < Constraint
23
- attr_reader :constraints
24
-
25
- def initialize(*constraints)
26
- @constraints = constraints
27
- end
28
-
29
- def value(v)
30
- exception = nil
31
-
32
- constraints.each do |c|
33
- result = c.value(v)
34
- if result.is_a?(InvalidValue)
35
- exception ||= result
36
- else
37
- return result
38
- end
39
- end
40
-
41
- exception
42
- end
43
-
44
- def |(other)
45
- constraints << other
46
- self
47
- end
48
-
49
- def ==(other)
50
- super && constraints == other.constraints
51
- end
52
- end
53
-
54
- class AndConstraint < Constraint
55
- attr_reader :constraints
56
-
57
- def initialize(*constraints)
58
- @constraints = constraints
59
- end
60
-
61
- def value(v)
62
- constraints.each do |c|
63
- v = c.value(v)
64
- return v if v.is_a?(InvalidValue)
65
- end
66
- v
67
- end
68
-
69
- def &(other)
70
- constraints << other
71
- self
72
- end
73
-
74
- def ==(other)
75
- super && constraints == other.constraints
76
- end
77
- end
78
- end
79
-
1
+ require 'stronger_parameters/constraint'
80
2
  require 'stronger_parameters/constraints/string_constraint'
81
3
  require 'stronger_parameters/constraints/float_constraint'
82
4
  require 'stronger_parameters/constraints/date_time_constraint'
@@ -1,3 +1,3 @@
1
1
  module StrongerParameters
2
- VERSION = '2.6.0'
2
+ VERSION = '2.6.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stronger_parameters
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.0
4
+ version: 2.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mick Staugaard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-23 00:00:00.000000000 Z
11
+ date: 2017-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,34 +52,6 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: guard
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: guard-minitest
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
55
  - !ruby/object:Gem::Dependency
84
56
  name: minitest-rails
85
57
  requirement: !ruby/object:Gem::Requirement
@@ -179,6 +151,7 @@ extra_rdoc_files: []
179
151
  files:
180
152
  - README.md
181
153
  - lib/stronger_parameters.rb
154
+ - lib/stronger_parameters/constraint.rb
182
155
  - lib/stronger_parameters/constraints.rb
183
156
  - lib/stronger_parameters/constraints/array_constraint.rb
184
157
  - lib/stronger_parameters/constraints/boolean_constraint.rb
@@ -218,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
218
191
  version: '0'
219
192
  requirements: []
220
193
  rubyforge_project:
221
- rubygems_version: 2.4.5.1
194
+ rubygems_version: 2.5.2
222
195
  signing_key:
223
196
  specification_version: 4
224
197
  summary: Type checking and type casting of parameters for Action Pack