tramway-api 1.8.6.7 → 1.8.6.12

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: 3206561c6202bb16eb547409a92afc1ffd3bd0577ab5924f0ba9142b2d2da5f7
4
- data.tar.gz: fc82ca7b002060d3f2a1d49d723a26d0405f5765ffd34a0b7b6a287914d68018
3
+ metadata.gz: 1c7fde28a2dba38baca9b59921296f203bee015e5065567cbfc8c818e49c15c9
4
+ data.tar.gz: e54a9190f07f0f3b78485f6667d1585a2847ec4ae0503e14362afe5a60cafbe3
5
5
  SHA512:
6
- metadata.gz: 9311be67f963e06248ab95056f9e20a40d819b706e8ce9814dbe28b8c063439dac7ebc42bc7ef9f2f3495579db8fd641a9db6032ea9ef4ebbd7847d1c008987d
7
- data.tar.gz: 6a0baa01d8e34556901407c738ceacf3facb379b6dbf5a27df2834347de75d79ca3bcf524f159d4a95fea9fc37e2eea8cf45a54f25f028e9bb1f443705f934b0
6
+ metadata.gz: 34d26aaadfe0f49d721903fabe39147b4c577cd74c3a8b0983435a5066121950a73915f9ea242adde527d2964bc24891ddf0e3ce523f797ad94a91cd7ae18cce
7
+ data.tar.gz: 8e51f5fb8e026a090a086d3f293356bdf35c272d5dc0dc5382ec4f2500735824e7a7770f4cf1ea591b5586dbe2c1f960adbfbc188f95b4fc432376a3b56a2847
@@ -6,6 +6,7 @@ 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 :application
9
10
 
10
11
  private
11
12
 
@@ -4,8 +4,6 @@ module Tramway
4
4
  module Api
5
5
  module V1
6
6
  class ApplicationController < ::Tramway::Api::ApplicationController
7
- before_action :application
8
-
9
7
  def render_errors_for(model)
10
8
  render json: model, status: :unprocessable_entity, serializer: ::Tramway::Api::V1::ErrorSerializer
11
9
  end
@@ -72,7 +70,7 @@ module Tramway
72
70
  action_is_available = checking_roles.map do |role|
73
71
  Tramway::Api.action_is_available(
74
72
  action: action_name.to_sym,
75
- project: (@application_engine || @application.name),
73
+ project: (@application_engine || application_name),
76
74
  role: role,
77
75
  model_name: params[:model],
78
76
  current_user: current_user
@@ -93,7 +91,7 @@ module Tramway
93
91
  def authenticate_user_if_needed
94
92
  action_is_open = Tramway::Api.action_is_available(
95
93
  action: action_name.to_sym,
96
- project: (@application_engine || @application.name),
94
+ project: (@application_engine || application_name),
97
95
  model_name: params[:model]
98
96
  )
99
97
  head(:unauthorized) && return if !current_user && !action_is_open
@@ -111,6 +109,15 @@ module Tramway
111
109
 
112
110
  protected
113
111
 
112
+ def application_name
113
+ @application ||= Tramway::Core.application&.model_class&.first || Tramway::Core.application
114
+ begin
115
+ @application.name
116
+ rescue
117
+ raise("Tramway::Api @application not initialized, Tramway::Core.application: #{::Tramway::Core.application}, model_class: #{Tramway::Core.application&.model_class }")
118
+ end
119
+ end
120
+
114
121
  def model_class
115
122
  params[:model].constantize
116
123
  rescue ActiveSupport::Concern::MultipleIncludedBlocks => e
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Tramway
4
4
  module Api
5
- VERSION = '1.8.6.7'
5
+ VERSION = '1.8.6.12'
6
6
  end
7
7
  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.8.6.7
4
+ version: 1.8.6.12
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-03-03 00:00:00.000000000 Z
11
+ date: 2021-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers