format_restricter_rails 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/format_restricter_rails/includes.rb +8 -12
- data/lib/format_restricter_rails/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4972618603956be5371074aff97c5789b6aec167
|
4
|
+
data.tar.gz: 627c68d3c620600806fd4553cb310dfa67ed3845
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35317de7978900af29f0452fa8eda71db806ab3a65b817fe931da560a692e98ee4649b7c77eaabae7be0c0f0d8f342b841c748d9bc32d389adfd8dae11cc31a0
|
7
|
+
data.tar.gz: aed2f149cbb0e918fa32a80a571867b93f66e9b58f724cb7b2b441e63975f38110f932b50251e4ac091f6c799702df1d1f53ae6b13be56934d43b1174dcd587c
|
data/CHANGELOG.md
CHANGED
@@ -4,28 +4,24 @@ module FormatRestricterRails
|
|
4
4
|
def self.included(base)
|
5
5
|
base.extend(ClassMethods)
|
6
6
|
base.instance_eval do
|
7
|
-
private_class_method :
|
7
|
+
private_class_method :register_before_action
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
11
|
module ClassMethods
|
12
12
|
def restrict_formats_to(*args)
|
13
13
|
options = args.extract_options!
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
allowed_formats = args.collect {|e| e.to_sym}
|
15
|
+
register_before_action(options, allowed_formats)
|
16
|
+
end
|
17
|
+
|
18
|
+
def register_before_action(options, allowed_formats)
|
19
|
+
before_action(options) do |controller|
|
20
|
+
unless allowed_formats.include?(request.format.symbol)
|
19
21
|
render nothing: true, status: 406
|
20
22
|
end
|
21
23
|
end
|
22
24
|
end
|
23
|
-
|
24
|
-
def normalize_option(options, key)
|
25
|
-
value = options.fetch(key, [])
|
26
|
-
value = [value] unless value.is_a?(Array)
|
27
|
-
value.collect {|e| e.to_sym}
|
28
|
-
end
|
29
25
|
end
|
30
26
|
end
|
31
27
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: format_restricter_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roberts
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|