effective_resources 1.8.24 → 1.8.28
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/effective_resources_helper.rb +2 -0
- data/app/models/concerns/effective_after_commit.rb +1 -1
- data/app/models/effective/after_commit.rb +2 -7
- data/app/models/effective/resources/instance.rb +1 -1
- data/app/models/effective/resources/sql.rb +6 -4
- data/lib/effective_resources/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: 841e6d1f903229208d1ad3b881b7fe32b75a851a28a3b2d0b8cea6062fac9afb
|
4
|
+
data.tar.gz: ddea9ed6121e5b34c35227bff21714f15a245bd73018531a265d281a289bcbae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd5f342a636e0beb84070ed95f0580dd94c1e8ec9a5ca1a6d6f8b155eef1198bf2dffb16f5da707727f33b3706467890581a8d560a5f027ebff7c6b6679f073d
|
7
|
+
data.tar.gz: 48cc4045db4e741cfe9c457cee3d7b38d464e4631d347a9e1dea118b7de62aa768145682f7c9accc1b0e5d9c36b60b289ee105f9e8e150b6fbcecc72492e97a7
|
@@ -59,6 +59,8 @@ module EffectiveResourcesHelper
|
|
59
59
|
# locals: {} render locals
|
60
60
|
# you can also pass all action names and true/false such as edit: true, show: false
|
61
61
|
def render_resource_actions(resource, atts = {}, &block)
|
62
|
+
return ''.html_safe if resource.blank?
|
63
|
+
|
62
64
|
unless resource.kind_of?(ActiveRecord::Base) || resource.kind_of?(Class) || resource.kind_of?(Array) || resource.class.ancestors.include?(ActiveModel::Model)
|
63
65
|
raise 'expected first argument to be an ActiveRecord::Base object or Array of objects'
|
64
66
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# EffectiveAfterCommit
|
2
2
|
#
|
3
|
+
# Execute code after the ActiveRecord transaction has committed
|
3
4
|
# Inspired by https://github.com/Envek/after_commit_everywhere
|
4
5
|
#
|
5
6
|
# This is automatically included into ActiveRecord::Base
|
@@ -16,7 +17,6 @@ module EffectiveAfterCommit
|
|
16
17
|
|
17
18
|
def before_commit(connection: self.class.connection, &callback)
|
18
19
|
raise(NotImplementedError, "#{__method__} works only with Rails 5.0+") if ActiveRecord::VERSION::MAJOR < 5
|
19
|
-
|
20
20
|
Effective::AfterCommit.register_callback(connection: connection, name: __method__, callback: callback, no_tx_action: :warn_and_execute)
|
21
21
|
end
|
22
22
|
|
@@ -1,8 +1,7 @@
|
|
1
1
|
module Effective
|
2
2
|
class AfterCommit
|
3
3
|
|
4
|
-
def initialize(
|
5
|
-
@connection = connection
|
4
|
+
def initialize(**handlers)
|
6
5
|
@handlers = handlers
|
7
6
|
end
|
8
7
|
|
@@ -26,10 +25,6 @@ module Effective
|
|
26
25
|
@handlers[:after_rollback]&.call
|
27
26
|
end
|
28
27
|
|
29
|
-
def add_to_transaction(*)
|
30
|
-
@connection.add_transaction_record(self)
|
31
|
-
end
|
32
|
-
|
33
28
|
def self.register_callback(connection:, name:, no_tx_action:, callback:)
|
34
29
|
raise ArgumentError, "#{name} expected a block" unless callback
|
35
30
|
|
@@ -45,7 +40,7 @@ module Effective
|
|
45
40
|
end
|
46
41
|
end
|
47
42
|
|
48
|
-
after_commit = Effective::AfterCommit.new(
|
43
|
+
after_commit = Effective::AfterCommit.new("#{name}": callback)
|
49
44
|
connection.add_transaction_record(after_commit)
|
50
45
|
end
|
51
46
|
|
@@ -8,7 +8,7 @@ module Effective
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def columns
|
11
|
-
klass.columns
|
11
|
+
klass.respond_to?(:columns) ? klass.columns : []
|
12
12
|
end
|
13
13
|
|
14
14
|
def column_names
|
@@ -40,9 +40,11 @@ module Effective
|
|
40
40
|
def sql_type(name)
|
41
41
|
name = name.to_s.split('.').first
|
42
42
|
|
43
|
-
if belongs_to(name)
|
44
|
-
|
45
|
-
|
43
|
+
return :belongs_to if belongs_to(name)
|
44
|
+
|
45
|
+
column = column(name)
|
46
|
+
|
47
|
+
if column.present?
|
46
48
|
column.type
|
47
49
|
elsif has_many(name)
|
48
50
|
:has_many
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_resources
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.8.
|
4
|
+
version: 1.8.28
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|