grape-utils 0.1.3 → 0.2.1

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: 56f2704d0f802aa4a8916b0785558f18b98e2d4177ad065375ce5cc78e93e002
4
- data.tar.gz: 787016613713840721824e1fbed84597cb25130e3b71bc36ceeff56b22faa0c1
3
+ metadata.gz: e4de07af6a0a76be7de3cbaca6f471df35c39d4a5264b7b20a291b4b7b91eaa0
4
+ data.tar.gz: f1bc5fd0e68d82afb6e102128821bde2c4a60c3354f69848821b7e7c99b58f88
5
5
  SHA512:
6
- metadata.gz: 50035d9d19c2d8b8cb6ac341867d01d3fd64df15f68d55f2005646918be5d80c1313aa92a46e7775b539ae35bc93bc53d665072e946f3d47502e30b237f54901
7
- data.tar.gz: 836f7914eca85a16ab5e7ffef11400ec4ca9e6b00b887ad304accb4f700d212528434b46694dd6dd5624d584c14ac455f17279f44716f646d69308aaa697baf8
6
+ metadata.gz: 9c86ff37f3050bb63efd89d8bbda4ed3b864b5ae3032aa654398b89d103608f7a253e5c51892a15d306cd884d812a12490333d2697d844d9553bf6b6fbc8c09d
7
+ data.tar.gz: 120f5acc64df69eeeb7928a8996d66ed661d6fce52393d93b050a04a226a5f043770113c57638b48913341e2aaedcec6e4e289fb859ed34c2e31d2dc95aa762b
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- grape-utils (0.1.3)
4
+ grape-utils (0.2.1)
5
5
  grape
6
6
  grape-entity
7
7
  grape-kaminari
@@ -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
@@ -13,7 +13,8 @@ module Grape
13
13
  mount Templates::Create, with: { model: configuration[:model],
14
14
  scope: configuration[:scope],
15
15
  entity: configuration[:entity],
16
- required_params: configuration[:required_params] }
16
+ required_params: configuration[:required_params],
17
+ default_params: configuration[:default_params] }
17
18
 
18
19
  mount Templates::Show, with: { model: configuration[:model],
19
20
  scope: configuration[:scope],
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Grape
4
4
  module Utils
5
- VERSION = "0.1.3"
5
+ VERSION = "0.2.1"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nix41