rails-rapido 0.9.7 → 0.9.8

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
  SHA256:
3
- metadata.gz: 4f94a2c707b7325512f48fee292918d01321378d6cfb6d87bbe9dc92e71a60ed
4
- data.tar.gz: 954e3e1b070f353a3f4023202f301f52dc620498ff54aeea1cf7bc8e65a5dfd4
3
+ metadata.gz: ccf726284964572386ae84aba1d867157c1b91133717d6d236d0a9649124643d
4
+ data.tar.gz: e8ea92e83433412fe2b5ef62f306e23faa2ccc3b3bc62c26ffeb28022447e778
5
5
  SHA512:
6
- metadata.gz: 1a92e60537cca20540113fb1b6186ac9469e11d024127ddeda4391249a926909897198cc56472d7cdeeb80a18d41922601615199934ffc65cd1c993528662c63
7
- data.tar.gz: b08530e8028fefcff3d737bb5d6ebd2580fe7949f0eda51b3c7747644433c56c800b4afb901d4b4a49e113fb384b37472336d097d595a722e5530dbb2cf9211a
6
+ metadata.gz: 70a0e264fecd2e4e0dfcf554b75f1e5b3c2e3391d99bbfa6a78e7fd015aa41150a923ad58461c968b97781e001a8f9e6bd3609d40be79f8bd3106005dc24e3b2
7
+ data.tar.gz: 91ea1c8d258c14017b4e88fe4933133f714dd2460d1bf6cefed0190b9210e04eaa3ca8e5ddeb54051cf6af9c5cffdb522c7c990e97590a1d62378c86184b7150
@@ -19,6 +19,8 @@ module Rapido
19
19
 
20
20
  before_action :permit_only_allowed_actions
21
21
 
22
+ before_action :permit_only_allowed_formats
23
+
22
24
  before_action :permit_only_if
23
25
  end
24
26
 
@@ -157,6 +159,14 @@ module Rapido
157
159
  head :unauthorized unless allowed_actions.include?(params[:action].to_sym)
158
160
  end
159
161
 
162
+ def permit_only_allowed_formats
163
+ f = params[:format]&.to_sym
164
+ unless (!f || f == :json) || (allowed_formats && allowed_formats.include?(f))
165
+ binding.pry
166
+ head :not_found
167
+ end
168
+ end
169
+
160
170
  def permit_only_if
161
171
  if(allow_if)
162
172
  unless (allow_if.is_a?(Symbol) ? send(allow_if) : instance_eval(&allow_if))
@@ -28,6 +28,10 @@ module Rapido
28
28
  @allowed_actions = ary
29
29
  end
30
30
 
31
+ def allowed_formats(*ary)
32
+ @allowed_formats = ary
33
+ end
34
+
31
35
  def allow_if(str = nil, &block)
32
36
  @allow_if = str || block
33
37
  end
@@ -105,6 +109,10 @@ module Rapido
105
109
  setting(:allowed_actions)
106
110
  end
107
111
 
112
+ def allowed_formats
113
+ setting(:allowed_formats)
114
+ end
115
+
108
116
  def allow_if
109
117
  setting(:allow_if)
110
118
  end
@@ -1,3 +1,3 @@
1
1
  module Rapido
2
- VERSION = '0.9.7'
2
+ VERSION = '0.9.8'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-rapido
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.7
4
+ version: 0.9.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Kirst
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-03 00:00:00.000000000 Z
11
+ date: 2022-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler