api_me 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/api_me.rb +15 -7
- data/lib/api_me/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: e70094d4fd7b9ae7f7cfddc4dbfe9cec2e94d3ef
|
4
|
+
data.tar.gz: 698e8957b40252211d1f6ee22ff5fa05ab19cb79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b75592dd259a25e71a5ed7af2ff43be82aa51afb939c79ced4f249b76da2954c8c0bfd5ae4881cf748984ce50760935e5294a4f8466a9a143752e491057273b2
|
7
|
+
data.tar.gz: e04298b570816de02a33a062241f234b0da3421d89bf6bad9668fd04bd083b5285c53c538c52ea3cadc4f8bb60d218388dfdd6c5ae7bc47f94ade02be659de07
|
data/lib/api_me.rb
CHANGED
@@ -65,13 +65,9 @@ module ApiMe
|
|
65
65
|
# the top level ids array param. Would eventually like
|
66
66
|
# to move to support the jsonapi.org standard closer.
|
67
67
|
def index
|
68
|
-
|
69
|
-
@
|
70
|
-
@
|
71
|
-
scope: @scoped_objects,
|
72
|
-
filters: (filter_params || {}).merge(ids_filter_hash)
|
73
|
-
)
|
74
|
-
@pagination_object = ApiMe::Pagination.new(scope: @filter_object.results, page_params: params[:page])
|
68
|
+
@policy_scope = policy_scope(resource_scope)
|
69
|
+
@filter_scope = filter_scope(@policy_scope)
|
70
|
+
@pagination_object = ApiMe::Pagination.new(scope: @filter_scope, page_params: params[:page])
|
75
71
|
|
76
72
|
render json: @pagination_object.results, each_serializer: serializer_klass, meta: { page: @pagination_object.page_meta }
|
77
73
|
end
|
@@ -151,10 +147,22 @@ module ApiMe
|
|
151
147
|
def resource_scope
|
152
148
|
model_klass.all
|
153
149
|
end
|
150
|
+
|
151
|
+
def filter_scope(scope)
|
152
|
+
filter_klass.new(
|
153
|
+
scope: scope,
|
154
|
+
filters: filters_hash
|
155
|
+
).results
|
156
|
+
end
|
154
157
|
|
155
158
|
def params_klass_symbol
|
156
159
|
model_klass.name.demodulize.underscore.to_sym
|
157
160
|
end
|
161
|
+
|
162
|
+
def filters_hash
|
163
|
+
ids_filter_hash = params[:ids] ? { ids: params[:ids] } : {}
|
164
|
+
(filter_params || {}).merge(ids_filter_hash)
|
165
|
+
end
|
158
166
|
|
159
167
|
def filter_params
|
160
168
|
params[:filters]
|
data/lib/api_me/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: api_me
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Clopton
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-05-
|
12
|
+
date: 2016-05-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|