friendly_routes 0.4.0 → 0.4.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: e2d3509ebae256e805600bb631718d9489eeaf73
4
- data.tar.gz: dd5d986628e21c2d693f579e1ab621bb3a259161
3
+ metadata.gz: 5e72b84173e2bf1383042a2feda7605f63cec246
4
+ data.tar.gz: 42589d7a55fb9e067265d305fa1dbdbd83fe6d24
5
5
  SHA512:
6
- metadata.gz: e9aed8430ef5abc1f2e6fffcd3956022c0ab30904d7690a9c027c6c2c5f4edec643c97ed58a8ec60da8fc098b67406ab0d0c71295e8590f93808d80e44c1de2f
7
- data.tar.gz: 14e92badb00980a1bb3efb5a134e713146920dc8c3c6aa71baa7c28623c65f9fa05c1c54f4d2cf12e5ed1d98babeb4dc364408d2c9149ac19116e106895a9d32
6
+ metadata.gz: 8c16dbcf2533f90de49de5636336f0e89f7c1d50d7f28aa68b3266eabdc93e4252b04d48f5c0074a7c4277ef551d2525909e92aae5a623dc72356835229a5699
7
+ data.tar.gz: 39e011306c64d601a9c70a2da3d8a2dcd4469fbc81dc767c65affa1fc38e7fc7cfce7505039dff9ffd47e9e21d93f6006b936d37caafce3056359ea0b546292d
@@ -22,21 +22,21 @@ module FriendlyRoutes
22
22
  # @param [String] value request value
23
23
  # @return [Boolean]
24
24
  def parse(value)
25
- value == @true
25
+ (value == @true).to_s
26
26
  end
27
27
 
28
28
  # (see Base#compose)
29
- # @param [Boolean] value
29
+ # @param [Boolean, String] value boolean, or "True"/"False" strings
30
30
  # @return [String] request value
31
31
  def compose(value)
32
- value ? @true : @false
32
+ value == true || value == 'true' ? @true : @false
33
33
  end
34
34
 
35
35
  # (see Base#allowed?)
36
- # @param [Boolean] value
36
+ # @param [Boolean, String] value boolean, or "True"/"False" strings
37
37
  # @return [Boolean]
38
38
  def allowed?(value)
39
- [true, false].include? value
39
+ [true, false, 'true', 'false'].include? value
40
40
  end
41
41
 
42
42
  private
@@ -10,6 +10,9 @@ module FriendlyRoutes
10
10
  super(:collection, name, optional)
11
11
  @hash = hash
12
12
  check_params
13
+ @hash = @hash.map do |k, v|
14
+ [k, v.try(:to_s) || v]
15
+ end.to_h
13
16
  end
14
17
 
15
18
  def constraints
@@ -27,14 +30,14 @@ module FriendlyRoutes
27
30
  # @param [Object] value hash value
28
31
  # @return [String, Symbol] hash key
29
32
  def compose(value)
30
- @hash.key(value)
33
+ @hash.key(value) || @hash.key(value.try(:to_s))
31
34
  end
32
35
 
33
36
  # (see Base#allowed?)
34
- # @param [Integer] value hash value
37
+ # @param [Object] value hash value
35
38
  # @return [Boolean]
36
39
  def allowed?(value)
37
- @hash.values.include?(value)
40
+ @hash.values.include?(value) || @hash.values.include?(value.try(:to_s))
38
41
  end
39
42
 
40
43
  private
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FriendlyRoutes
4
- VERSION = '0.4.0'
4
+ VERSION = '0.4.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: friendly_routes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roman Gritsay
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-04 00:00:00.000000000 Z
11
+ date: 2016-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails