otpor 0.1.1 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/otpor/json_response.rb +17 -1
- data/lib/otpor/templates/shared/response.json.jbuilder +1 -0
- data/lib/otpor/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4340270f71be5b4cbd00baccd71c95a2c033a39471929a462fb03afde8130aa8
|
4
|
+
data.tar.gz: a409d5bda7dece03040e0dcb2cf4708aa17d686e554526430309246aa961562f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef54d3dd06854ec8c2fd6eccb796d67b8e6593e178c2586465d9728ae621f328814fde258bb7da2b25d71127b2f5bf73834bd98724f46c1119f7341bf10bebe8
|
7
|
+
data.tar.gz: 1ad41976acf90f647ca04b7d9d9857a9102211390c19fe25f192fdf864e04e02c8e360a955d0165deea90db6a2faa64f8ed2306fab2f2eb3ac3b0bc3aff59128
|
data/lib/otpor/json_response.rb
CHANGED
@@ -103,7 +103,23 @@ module Otpor
|
|
103
103
|
end
|
104
104
|
|
105
105
|
def infer_meta
|
106
|
-
|
106
|
+
pagination = infer_pagination
|
107
|
+
api_version = infer_api_version
|
108
|
+
|
109
|
+
return nil if pagination.nil? && api_version.nil?
|
110
|
+
|
111
|
+
meta = {}
|
112
|
+
meta = meta.merge(pagination) if pagination.present?
|
113
|
+
meta = meta.merge(api_version) if api_version.present?
|
114
|
+
meta
|
115
|
+
end
|
116
|
+
|
117
|
+
def infer_api_version
|
118
|
+
{ api_version: "v#{::Regexp.last_match(1)}" } if request.path =~ %r{/v(\d+)/}
|
119
|
+
end
|
120
|
+
|
121
|
+
def infer_pagination
|
122
|
+
@instance_variables.each do |_key, value|
|
107
123
|
next unless value.respond_to?(:total_pages)
|
108
124
|
|
109
125
|
return {
|
data/lib/otpor/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: otpor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Renan Garcia
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-09-
|
11
|
+
date: 2024-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jbuilder
|