sinatra-my-params 0.0.5 → 0.0.6

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
  SHA256:
3
- metadata.gz: 747bacbce6ab90027f92e29c45475964414cda4f62ad362339f1fd515323fcf3
4
- data.tar.gz: 2c0d6582d40e18230e5d97e29ddff20484d86163366bc23e7aa24e67c255d9a6
3
+ metadata.gz: 004ffa9a419a6ca94f76672d37e9cd242aca9f69ca1c92ada97ac135a1329abc
4
+ data.tar.gz: a0dcc3771df668d6356a4443e98cd1bcb4d1ad6e877076bbc3cc5f99e904a078
5
5
  SHA512:
6
- metadata.gz: b2b7b1e994250fce4fbabe3cf9571b62dc6432c7965d81897b54889a1be64198fb0dff9ba1ab83e91462985ee7644a5a3b00188b600b1d7fa4431d72e0ee99d6
7
- data.tar.gz: e502b5deafbeb12839eb772b3be83720160ac8f1c99950fa527dcdef9da2e04df7aa55ffee1a32c6e037fa9931e3ec3f28e2e3470e545781e9855245b5db3d5d
6
+ metadata.gz: 04d4e285426806ac16f36f7b757eed7682d1502c272dedf7f0fd3291234e9cf3eb611c52c25a73cca3f3b29d6190ed83523cde335125599cfb92f81e2eee8c17
7
+ data.tar.gz: 861c6fc9858865ac856e66ed030f5bd8ac7005b268c3a3a2cb66deec648feec52b1c596808e6736b4495bf20e1fe7e4e818ccbfa8ebb24fe2727d77511bb13cf
data/lib/permit_params.rb CHANGED
@@ -20,8 +20,11 @@ module PermitParams
20
20
  private
21
21
 
22
22
  Boolean = :boolean
23
+ Any = :any
23
24
 
24
25
  def coerce(param, type, strong_validation = false, options = {})
26
+ return param if type == Any
27
+
25
28
  begin
26
29
  return nil if param.nil?
27
30
  return param if (param.is_a?(type) rescue false)
@@ -6,6 +6,10 @@ require "rack/test"
6
6
  include PermitParams
7
7
 
8
8
  describe "exceptions" do
9
+ before do
10
+ class TestClass; end
11
+ end
12
+
9
13
  it "should raise error when at least one param is invalid" do
10
14
  input = { param_1: "a" }
11
15
  expect{
@@ -91,6 +95,15 @@ describe "exceptions" do
91
95
  )
92
96
  end
93
97
 
98
+ it "returns the paramter without casting if Any" do
99
+ input = { param_1: "1" }
100
+ output = { param_1: "1" }
101
+ expect(output).to eq permitted_params(input, { param_1: Any })
102
+
103
+ input = { param_1: TestClass.new }
104
+ expect(input).to eq permitted_params(input, { param_1: Any })
105
+ end
106
+
94
107
  it "should remove a string when a pemitted is integer" do
95
108
  input = { param_1: "a string" }
96
109
  output = {}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-my-params
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marco Aviles