tramway-api 1.4.1 → 1.4.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -2
- data/app/controllers/tramway/api/v1/records_controller.rb +3 -2
- data/lib/tramway/api/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: 04f5055e00ef3608b436ae004240b26578fb7c9862eee1935e6fbfb6c299e1c6
|
4
|
+
data.tar.gz: 8269beafa9c7c8ca209d6eb4f35ce5ba7f7539106acd8e2ec1d984c386cff225
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86986d7a77393d34502750ffeb93240c71acdba6666df665f33916a815ce25b25038296a0bd5b603acfdda793354c5497f5a3b3375feeb3b4d11bcdba4aa6388
|
7
|
+
data.tar.gz: a6aed10bc3451c21abf1528893e06f778beb2b669ac89a17b0ca04dc500bf098628e35d8c34f674e5a34ef00dcba3bd51b5dcaeeadc8a7686cfc476411ff0c8b
|
data/README.md
CHANGED
@@ -89,7 +89,7 @@ Create file `config/initializers/tramway.rb`
|
|
89
89
|
|
90
90
|
```ruby
|
91
91
|
::Tramway::Api.auth_config = { user_model: User, auth_attributes: %i[email username] }
|
92
|
-
::Tramway::Api.set_available_models user: %i[create update]
|
92
|
+
::Tramway::Api.set_available_models user: { open: %i[create], closed: %i[update] }
|
93
93
|
```
|
94
94
|
|
95
95
|
Run `rails g tramway:core:install`
|
@@ -271,7 +271,10 @@ this model must have field `password_digest`, because we use `bcrypt` gem for au
|
|
271
271
|
|
272
272
|
Sets ActiveRecord models which will be used in API
|
273
273
|
|
274
|
-
Argument is a hash. Keys are underscored models names, values are
|
274
|
+
Argument is a hash. Keys are underscored models names, values are hashes with actions of available methods for every model.
|
275
|
+
* `open` key means that this action will be used without authentication
|
276
|
+
* `closed` key means that this action will be used with authentication
|
277
|
+
|
275
278
|
|
276
279
|
Enabled methods:
|
277
280
|
|
@@ -55,8 +55,9 @@ module Tramway::Api::V1
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def check_available_model_action
|
58
|
-
|
59
|
-
|
58
|
+
open_actions = Tramway::Api.available_models[model_class.to_s][:open]&.map(&:to_s) || []
|
59
|
+
closed_actions = Tramway::Api.available_models[model_class.to_s][:closed]&.map(&:to_s) || []
|
60
|
+
head :unprocessable_entity and return unless action_name.in? open_actions + closed_actions
|
60
61
|
end
|
61
62
|
|
62
63
|
def authenticate_user_if_needed
|
data/lib/tramway/api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tramway-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.1
|
4
|
+
version: 1.4.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Kalashnikov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09-
|
11
|
+
date: 2019-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: knock
|