tramway-api 1.4.1 → 1.4.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ec1302e6c87545200be1aafc619be2179f680ba24cbfa80b7876cbb66062411b
4
- data.tar.gz: ef2806fab92a090ee0524a855b6ece6960a349ec5952e7c4e76feb3b4c3f0469
3
+ metadata.gz: 04f5055e00ef3608b436ae004240b26578fb7c9862eee1935e6fbfb6c299e1c6
4
+ data.tar.gz: 8269beafa9c7c8ca209d6eb4f35ce5ba7f7539106acd8e2ec1d984c386cff225
5
5
  SHA512:
6
- metadata.gz: 9016f340db67e2c4a05a3ec3f13d57cc104c4354980c5f09111bc70b1c9cecd778e108998482e8b049c8a356490bb5170f27583554fd910216385d8847425408
7
- data.tar.gz: 23dd222a388b24c3d01ef0c27004ef3478ec8e7c9f82bf1462ae07ec3f027ac333df69d602c1259295f57f2f6d0a8314f918f7b38e6e754053725df6c67fcf9e
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 arrays of available methods for every model.
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
- actions = Tramway::Api.available_models[model_class.to_s][:open]&.map(&:to_s) || [] + Tramway::Api.available_models[model_class.to_s][:closed]&.map(&:to_s) || []
59
- head :unprocessable_entity and return unless action_name.in? actions
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
@@ -1,5 +1,5 @@
1
1
  module Tramway
2
2
  module Api
3
- VERSION = '1.4.1'
3
+ VERSION = '1.4.1.1'
4
4
  end
5
5
  end
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-09 00:00:00.000000000 Z
11
+ date: 2019-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: knock