tramway-api 1.8.6.14 → 1.8.7.3
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11004151aa05f918b93dfcc0732fe11e69030074fd0f677470b8d8971bf15cb8
|
4
|
+
data.tar.gz: 966562fdf9a961d25ed49e70b509df1039b8009e49520374ccdc4667432053f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cda3e5383e1b5e8d18b6ca86b58a811fc44d58ad2a6d8a0a080d283081053a385d56d24c175687ab648232560128d3dbf7e4f11d2801e1819f927fa57900a61a
|
7
|
+
data.tar.gz: c6e6e8f9bbf3ae234ce5f5b415d946158b69a5ba281f0dc638ef0c4eaf5b742700cc661744fc7182d8bc71000e80cc61bca74a39efdb2c99ab430f83b6435d90
|
data/README.md
CHANGED
@@ -6,37 +6,6 @@ module Tramway
|
|
6
6
|
include ::Knock::Authenticable
|
7
7
|
protect_from_forgery with: :null_session, if: proc { |c| c.request.format == 'application/json' }
|
8
8
|
rescue_from ActiveRecord::RecordNotFound, with: :not_found if Rails.env.production?
|
9
|
-
before_action :load_application
|
10
|
-
|
11
|
-
def load_application
|
12
|
-
if engine_loaded(request).present?
|
13
|
-
build_application_with_engine engine_loaded request
|
14
|
-
elsif application_class(request).present?
|
15
|
-
@application = application_class(request).camelize.constantize.first
|
16
|
-
else
|
17
|
-
@application = application_object request
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
def build_application_with_engine(engine_loaded)
|
24
|
-
engine_module = "::Tramway::#{engine_loaded.camelize}".constantize
|
25
|
-
@application = "#{engine_module}::#{engine_module.application.to_s.camelize}".constantize.first
|
26
|
-
@application_engine = engine_loaded
|
27
|
-
end
|
28
|
-
|
29
|
-
def application_class(request)
|
30
|
-
Constraints::DomainConstraint.new(request.domain).application_class
|
31
|
-
end
|
32
|
-
|
33
|
-
def engine_loaded(request)
|
34
|
-
Constraints::DomainConstraint.new(request.domain).engine_loaded
|
35
|
-
end
|
36
|
-
|
37
|
-
def application_object(request)
|
38
|
-
Constraints::DomainConstraint.new(request.domain).application_object
|
39
|
-
end
|
40
9
|
|
41
10
|
def not_found
|
42
11
|
render json: { data: [] }, status: :not_found
|
@@ -66,7 +35,7 @@ module Tramway
|
|
66
35
|
user_based_model = params[:user_based_model].constantize
|
67
36
|
@entity ||=
|
68
37
|
if user_based_model.respond_to? :from_token_request
|
69
|
-
user_based_model.
|
38
|
+
user_based_model.from_token_request request
|
70
39
|
else
|
71
40
|
params[:auth] && find_user_by_auth_attributes
|
72
41
|
end
|
@@ -74,8 +43,8 @@ module Tramway
|
|
74
43
|
|
75
44
|
def find_user_by_auth_attributes
|
76
45
|
user_based_model = params[:user_based_model].constantize
|
77
|
-
Tramway::Api.auth_attributes[user_based_model].each do |attribute|
|
78
|
-
object = user_based_model.
|
46
|
+
Tramway::Api.auth_attributes[params[:user_based_model]].each do |attribute|
|
47
|
+
object = user_based_model.where.not(attribute => nil).find_by(attribute => auth_params[:login])
|
79
48
|
return object if object
|
80
49
|
end
|
81
50
|
nil
|
@@ -87,7 +56,7 @@ module Tramway
|
|
87
56
|
|
88
57
|
def current_user
|
89
58
|
Tramway::Api.user_based_models.map do |user_based_model|
|
90
|
-
send("current_#{user_based_model.name.underscore}") unless user_based_model == User
|
59
|
+
send("current_#{user_based_model.constantize.name.underscore}") unless user_based_model == User
|
91
60
|
end.compact.first
|
92
61
|
end
|
93
62
|
end
|
@@ -8,9 +8,11 @@ module Tramway::Api::V1
|
|
8
8
|
before_action :application
|
9
9
|
|
10
10
|
def index
|
11
|
-
collection = available_action_for_collection
|
11
|
+
@collection = available_action_for_collection
|
12
12
|
|
13
|
-
|
13
|
+
raise 'Collection has empty uuid. It should not be empty, because all records with empty uuid will not be rendered' if @collection.map(&:uuid).map(&:empty?).include? true
|
14
|
+
|
15
|
+
render json: @collection,
|
14
16
|
each_serializer: serializer_class,
|
15
17
|
include: '*',
|
16
18
|
status: :ok
|
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.8.
|
4
|
+
version: 1.8.7.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Kalashnikov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_model_serializers
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.10.
|
19
|
+
version: 0.10.12
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.10.
|
26
|
+
version: 0.10.12
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: knock
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0'
|
118
118
|
requirements: []
|
119
|
-
rubygems_version: 3.1
|
119
|
+
rubygems_version: 3.0.3.1
|
120
120
|
signing_key:
|
121
121
|
specification_version: 4
|
122
122
|
summary: Engine for api
|