hash_params 2.0.0 → 2.0.1

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
  SHA1:
3
- metadata.gz: 65d13d16e642e22b531b671ea8315bc477fd6bd3
4
- data.tar.gz: 5f600d5a2f1172920a37870367e9f8e232f35df1
3
+ metadata.gz: 18b9b33c318505732f31be28490a86c21f71fbb8
4
+ data.tar.gz: 85bea6b4b4586a471628133ca29f3fafdd184b78
5
5
  SHA512:
6
- metadata.gz: 6e7207b5832175aa5f2aa9b0e151c1537209d8effc8ad13d480275362d4b1ef0615428ab27151cfa8b7d048ec5f19b9b95af01490d1a016110271850c2edb102
7
- data.tar.gz: 1bf66afcaca1c077dabe5e9b46ad9f26201f4c9349f99aff490ce3df9cd102746327764f04be01e61636353d04144e1ba16f291ebb5755ee2ccf51db9519fee2
6
+ metadata.gz: 6cb584ef9c38be540b5f63183f44d265f58f4d7d9b9517da8aa4e5372114b54d3afa97ebbddce2e309b81feb9fa95cbf97a18b73dbb85928a52c80269b048a2a
7
+ data.tar.gz: dcabb95cc3e9b7e8e46672a3e5c2693b5bac428e14c09c65de93cc6c2af2ad51531d9f3f0f8f89a894daf97d30db16de7b8e7c456f6ae837bf1341916bebeb33
data/lib/hash_params.rb CHANGED
@@ -8,7 +8,7 @@ require_relative 'hash_params/binding_validator'
8
8
 
9
9
  module HashParams
10
10
  ENVIRONMENT = ENV['HASH_PARAMS_ENV'] || (defined?(Rails) && Rails.env) || ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'
11
- VERSION = '2.0.0'
11
+ VERSION = '2.0.1'
12
12
  extend HashParams::Validator
13
13
  end
14
14
 
@@ -11,7 +11,7 @@ module HashParams
11
11
  BindingValidator.new.with_binding(&code)
12
12
  end
13
13
 
14
- def validate(param, type, validations={})
14
+ def validate(param, type=nil, validations={})
15
15
 
16
16
  coercions = Array(validations[:coerce]) << type
17
17
 
@@ -77,7 +77,7 @@ module HashParams
77
77
 
78
78
  private
79
79
 
80
- def coerce(val, type, opts={})
80
+ def coerce(val, type=nil, opts={})
81
81
 
82
82
  # exceptions bubble up
83
83
  #order is important
@@ -104,6 +104,7 @@ module HashParams
104
104
  return type.call(val) if type.respond_to?(:call)
105
105
  #nothing but simple types left
106
106
  return val if val.is_a?(type)
107
+ return val.to_s.to_sym if type == Symbol
107
108
  return Integer(val) if type == Integer
108
109
  return Float(val) if type == Float
109
110
  return String(val) if type == String
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hash_params
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Uckun