grape-utils 0.2.0 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/grape_utils/helpers.rb +4 -0
- data/lib/grape_utils/templates/create.rb +2 -1
- data/lib/grape_utils/templates/update.rb +1 -1
- data/lib/grape_utils/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16b804ea2cda99755ecdd0f1c43479f3939afb892a3bcaa491b0799717b5d7f9
|
4
|
+
data.tar.gz: 62636d653739951419d35cfd544e6f03e9c0349dc8d32632c059fba913d60c73
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4bf969b5f6604df319c7f632252a9e4d7b670119e8294d0703a8ca1833754af6aa4e6dd4bf39b4c48f217e3282aabb29144bef3e3cfc490c236b81e4ad844544
|
7
|
+
data.tar.gz: 9a7617ce1c809103c55e109436020c1c31ec08352fe5c207cc2b5fa614782a095961e8e557ab25cbc4536bb0aebf4377aec43f69a5f50f0f2a4f2230fbc94bae
|
data/Gemfile.lock
CHANGED
data/lib/grape_utils/helpers.rb
CHANGED
@@ -11,6 +11,10 @@ module Grape
|
|
11
11
|
initial_scope = scope.is_a?(Proc) ? instance_eval(&scope) : scope
|
12
12
|
initial_scope || model.all
|
13
13
|
end
|
14
|
+
|
15
|
+
def default_params(configuration)
|
16
|
+
configuration.is_a?(Proc) ? instance_eval(&configuration) : configuration || {}
|
17
|
+
end
|
14
18
|
end
|
15
19
|
end
|
16
20
|
end
|
@@ -14,7 +14,8 @@ module Grape
|
|
14
14
|
using: configuration[:entity].documentation
|
15
15
|
end
|
16
16
|
post do
|
17
|
-
default_params = configuration[:default_params]
|
17
|
+
default_params = default_params(configuration[:default_params])
|
18
|
+
puts "default_params: #{default_params}, #{default_params.merge(permitted_params)}"
|
18
19
|
resource = configuration[:model].create!(default_params.merge(permitted_params))
|
19
20
|
present resource, with: configuration[:entity]
|
20
21
|
end
|
@@ -14,7 +14,7 @@ module Grape
|
|
14
14
|
requires :none, using: configuration[:entity].documentation
|
15
15
|
end
|
16
16
|
patch do
|
17
|
-
scope = configuration[:scope]
|
17
|
+
scope = calculate_scope(scope: configuration[:scope], model: configuration[:model])
|
18
18
|
resource = scope.find_by!((configuration[:column_id] || :id) => params[:id])
|
19
19
|
resource.update!(permitted_params.except(:id))
|
20
20
|
|
data/lib/grape_utils/version.rb
CHANGED