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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9ef5eba619e3764fdc204b3e1b72ec0063b16c2319866688f4c8e7ff3808354d
4
- data.tar.gz: '09e02f90c4db8a1f0f416ec6ece7471db4e9ab865a4bac701a4977c9c6f4e18a'
3
+ metadata.gz: 841e6d1f903229208d1ad3b881b7fe32b75a851a28a3b2d0b8cea6062fac9afb
4
+ data.tar.gz: ddea9ed6121e5b34c35227bff21714f15a245bd73018531a265d281a289bcbae
5
5
  SHA512:
6
- metadata.gz: 65b2ec2e37dd19c24375b02533b86519733d83652b24fc131f267d625de17bdd0210efea61ca84e7186e2b3b0d5821a94e7faf1805665bf752c0b2636456eb8f
7
- data.tar.gz: 8bf7c81fd895011224ffa0ed49942bf3c8517ca7e7a2c8141820247c859014de9fa1eed17517b25ed5951bff7d904c091b165d4ab1f2710ad8e674c34d9a8d06
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(connection:, **handlers)
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(connection: connection, "#{name}": callback)
43
+ after_commit = Effective::AfterCommit.new("#{name}": callback)
49
44
  connection.add_transaction_record(after_commit)
50
45
  end
51
46
 
@@ -7,7 +7,7 @@ module Effective
7
7
  BLACKLIST = [:logged_changes, :trash]
8
8
 
9
9
  def instance
10
- @instance || klass.new
10
+ @instance || (klass.new if klass)
11
11
  end
12
12
 
13
13
  # called by effective_trash and effective_logging
@@ -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
- :belongs_to
45
- elsif (column = column(name))
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
@@ -1,3 +1,3 @@
1
1
  module EffectiveResources
2
- VERSION = '1.8.24'.freeze
2
+ VERSION = '1.8.28'.freeze
3
3
  end
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.24
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-06-02 00:00:00.000000000 Z
11
+ date: 2021-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails