stark_parameters 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZGUzNzI0OWE3OGRhNTRkOWJmYjg3NzU4NDAxY2I3OGU1NDI5MGEzNg==
5
+ data.tar.gz: !binary |-
6
+ NTE3ZTc5ODAwNzE1ZTM5YzBkMDgwOTI2Nzc1ZTJiNTZiYTRiZTY3OQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ NzIwMGQ2ZDI2Zjk4YTc1ZmI2MDZhY2U0M2ViZmIwNmNhMGIwY2ZjYjgyMTdm
10
+ ZGM3NTc1NWY0NTlhYzAyNmZkODljZTliN2VhMzQzYzYxNjMzMDdkNDMxN2Ez
11
+ ZDI2MDc2NzllNzY4ZjExNzc1OTUzZWI2ZWY0OTg3ZmIzZDIxODQ=
12
+ data.tar.gz: !binary |-
13
+ MjRkMjQwOWQ4NzdiN2VhOTc2MzgzZjAxNTRjYjhhYzYxMzhmZGJmZDdlYjE2
14
+ NDk5ZmJhMjExOTliMGJiMmNkZmM5YWYwZGE0ZWI4ZGY1MzI5OTQzODI4YjYx
15
+ NGNkOTBkZDY0MDhjNWQxMzQ4NjUxM2JmOTA2MTdiYzI5Mjk1NzU=
@@ -1,3 +1,3 @@
1
1
  module StarkParameters
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -51,14 +51,17 @@ module StarkParameters
51
51
  end
52
52
 
53
53
  def require_one(to_require, allow_nil = false)
54
- present_param = to_require.detect {|p| @params.include?(p) }
55
- value_presence_valid = allow_nil ? true : !@params.stringify_keys[present_param.to_s].nil?
56
- unless present_param && value_presence_valid
54
+ present_param = to_require.detect {|p| @params.include?(p) && (allow_nil || !@params[p].nil?) }
55
+ unless present_param && value_presence_valid(present_param, allow_nil)
57
56
  raise ActionController::ParameterMissing.new(to_require.join(" or "))
58
57
  end
59
58
  present_param
60
59
  end
61
60
 
61
+ def value_presence_valid(present_param, allow_nil)
62
+ allow_nil ? true : !@params.stringify_keys[present_param.to_s].nil?
63
+ end
64
+
62
65
  module ClassMethods
63
66
  attr_accessor :permitted_params, :presence_required_params, :presence_optional_params, :aliases
64
67
 
@@ -47,9 +47,9 @@ describe StarkParameters do
47
47
  end
48
48
 
49
49
  context "when required param is nil" do
50
- let(:params) { full_params["name"] = nil; full_params }
50
+ let(:params) { full_params["last_name"] = nil; full_params }
51
51
 
52
- it { expect{ validator.params }.to raise_error(ActionController::ParameterMissing) }
52
+ it { expect(validator.params.to_hash).to include("surname" => "Levick") }
53
53
  end
54
54
 
55
55
  describe "required param presence: true" do
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stark_parameters
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
5
- prerelease:
4
+ version: 0.1.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - rylev
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-03-26 00:00:00.000000000 Z
11
+ date: 2014-04-24 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: actionpack
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ! '>='
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ! '>='
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ! '>='
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ! '>='
44
39
  - !ruby/object:Gem::Version
@@ -46,7 +41,6 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rspec
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ! '>='
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ! '>='
60
53
  - !ruby/object:Gem::Version
@@ -78,27 +71,26 @@ files:
78
71
  - stark_parameters.gemspec
79
72
  homepage: ''
80
73
  licenses: []
74
+ metadata: {}
81
75
  post_install_message:
82
76
  rdoc_options: []
83
77
  require_paths:
84
78
  - lib
85
79
  required_ruby_version: !ruby/object:Gem::Requirement
86
- none: false
87
80
  requirements:
88
81
  - - ! '>='
89
82
  - !ruby/object:Gem::Version
90
83
  version: '0'
91
84
  required_rubygems_version: !ruby/object:Gem::Requirement
92
- none: false
93
85
  requirements:
94
86
  - - ! '>='
95
87
  - !ruby/object:Gem::Version
96
88
  version: '0'
97
89
  requirements: []
98
90
  rubyforge_project:
99
- rubygems_version: 1.8.23
91
+ rubygems_version: 2.2.2
100
92
  signing_key:
101
- specification_version: 3
93
+ specification_version: 4
102
94
  summary: Wraps Strong Parameters with additonal functionality
103
95
  test_files:
104
96
  - spec/lib/stark_parameters_spec.rb