acts_as_list 1.2.2 → 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/lib/acts_as_list/active_record/acts/list.rb +7 -4
- data/lib/acts_as_list/active_record/acts/position_column_method_definer.rb +14 -6
- data/lib/acts_as_list/active_record/acts/sequential_updates_method_definer.rb +15 -15
- data/lib/acts_as_list/active_record/acts/with_connection.rb +25 -0
- data/lib/acts_as_list/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8fb937125e21c3674aefbf6cce0dbc334380a975b3c0cbf1e13c79f43a4fecd4
|
4
|
+
data.tar.gz: ead5fb00d9321a35f409e7c005eeebfb66192d7e4952040f4008d557726e38df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8a8c099d4808b9f5c92eefd0a70f3b6f9b7e694b80f68a5b985bab159ec32be9f0256f5d7f9b053891e81d507eae9cb8c0a3fbb56e18646ce2e3202c10c6d68
|
7
|
+
data.tar.gz: 0f4f91c1879293d00012462f37f0cb3e801d88450369d6db52ab7c53a7abab6c4523a1a5b691ad0a9d937bc783fa44008770617c541a22ef35393b69f0afaf3c
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
6
6
|
|
7
7
|
## Unreleased
|
8
8
|
|
9
|
+
## v1.2.4 - 2024-11-20
|
10
|
+
|
11
|
+
### Added
|
12
|
+
- funding_uri to gemspec
|
13
|
+
|
14
|
+
## v1.2.3 - 2024-10-14
|
15
|
+
|
16
|
+
### Changed
|
17
|
+
- Use `.with_connection do |connection|` where possible instead of `.connection` [\#441](https://github.com/brendon/acts_as_list/pull/441) ([flood4life])
|
18
|
+
|
9
19
|
## v1.2.2 - 2024-07-16
|
10
20
|
|
11
21
|
### Fixed
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative './with_connection'
|
4
|
+
|
3
5
|
module ActiveRecord
|
4
6
|
module Acts #:nodoc:
|
5
7
|
module List #:nodoc:
|
@@ -459,7 +461,9 @@ module ActiveRecord
|
|
459
461
|
|
460
462
|
# When using raw column name it must be quoted otherwise it can raise syntax errors with SQL keywords (e.g. order)
|
461
463
|
def quoted_position_column
|
462
|
-
@_quoted_position_column ||= self.class.connection
|
464
|
+
@_quoted_position_column ||= ActiveRecord::Acts::List::WithConnection.new(self.class).call do |connection|
|
465
|
+
connection.quote_column_name(position_column)
|
466
|
+
end
|
463
467
|
end
|
464
468
|
|
465
469
|
# Used in order clauses
|
@@ -481,9 +485,8 @@ module ActiveRecord
|
|
481
485
|
requirement.satisfied_by?(version)
|
482
486
|
end
|
483
487
|
|
484
|
-
def primary_key_condition(id =
|
485
|
-
|
486
|
-
id ? primary_keys.zip(Array.wrap(id)).to_h : slice(*primary_keys)
|
488
|
+
def primary_key_condition(id = self.id)
|
489
|
+
{ self.class.primary_key => [id] }
|
487
490
|
end
|
488
491
|
end
|
489
492
|
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative './with_connection'
|
4
|
+
|
3
5
|
module ActiveRecord::Acts::List::PositionColumnMethodDefiner #:nodoc:
|
4
6
|
def self.call(caller_class, position_column, touch_on_update)
|
5
7
|
define_class_methods(caller_class, position_column, touch_on_update)
|
@@ -15,7 +17,9 @@ module ActiveRecord::Acts::List::PositionColumnMethodDefiner #:nodoc:
|
|
15
17
|
def self.define_class_methods(caller_class, position_column, touch_on_update)
|
16
18
|
caller_class.class_eval do
|
17
19
|
define_singleton_method :quoted_position_column do
|
18
|
-
@_quoted_position_column ||=
|
20
|
+
@_quoted_position_column ||= ActiveRecord::Acts::List::WithConnection.new(self).call do |connection|
|
21
|
+
connection.quote_column_name(position_column)
|
22
|
+
end
|
19
23
|
end
|
20
24
|
|
21
25
|
define_singleton_method :quoted_position_column_with_table_name do
|
@@ -72,18 +76,22 @@ module ActiveRecord::Acts::List::PositionColumnMethodDefiner #:nodoc:
|
|
72
76
|
cached_quoted_now = quoted_current_time_from_proper_timezone
|
73
77
|
|
74
78
|
timestamp_attributes_for_update_in_model.map do |attr|
|
75
|
-
|
79
|
+
ActiveRecord::Acts::List::WithConnection.new(self.class).call do |connection|
|
80
|
+
", #{connection.quote_column_name(attr)} = #{cached_quoted_now}"
|
81
|
+
end
|
76
82
|
end.join
|
77
83
|
end
|
78
84
|
|
79
85
|
private
|
80
86
|
|
81
87
|
def quoted_current_time_from_proper_timezone
|
82
|
-
self.class.connection
|
83
|
-
|
84
|
-
|
88
|
+
ActiveRecord::Acts::List::WithConnection.new(self.class).call do |connection|
|
89
|
+
connection.quote(
|
90
|
+
connection.quoted_date(
|
91
|
+
current_time_from_proper_timezone
|
92
|
+
)
|
85
93
|
)
|
86
|
-
|
94
|
+
end
|
87
95
|
end
|
88
96
|
end
|
89
97
|
end
|
@@ -1,24 +1,24 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative './with_connection'
|
4
|
+
|
3
5
|
module ActiveRecord::Acts::List::SequentialUpdatesMethodDefiner #:nodoc:
|
4
6
|
def self.call(caller_class, column, sequential_updates_option)
|
5
7
|
caller_class.class_eval do
|
6
8
|
define_method :sequential_updates? do
|
7
|
-
if
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
else
|
21
|
-
@sequential_updates
|
9
|
+
return @sequential_updates if defined?(@sequential_updates)
|
10
|
+
|
11
|
+
return @sequential_updates = sequential_updates_option unless sequential_updates_option.nil?
|
12
|
+
|
13
|
+
ActiveRecord::Acts::List::WithConnection.new(caller_class).call do |connection|
|
14
|
+
table_exists =
|
15
|
+
if active_record_version_is?('>= 5')
|
16
|
+
connection.data_source_exists?(caller_class.table_name)
|
17
|
+
else
|
18
|
+
connection.table_exists?(caller_class.table_name)
|
19
|
+
end
|
20
|
+
index_exists = connection.index_exists?(caller_class.table_name, column, unique: true)
|
21
|
+
@sequential_updates = table_exists && index_exists
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActiveRecord
|
4
|
+
module Acts
|
5
|
+
module List
|
6
|
+
class WithConnection
|
7
|
+
def initialize(recipient)
|
8
|
+
@recipient = recipient
|
9
|
+
end
|
10
|
+
|
11
|
+
attr_reader :recipient
|
12
|
+
|
13
|
+
def call
|
14
|
+
if recipient.respond_to?(:with_connection)
|
15
|
+
recipient.with_connection do |connection|
|
16
|
+
yield connection
|
17
|
+
end
|
18
|
+
else
|
19
|
+
yield recipient.connection
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/acts_as_list/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_list
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Swanand Pagnis
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-
|
12
|
+
date: 2024-11-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -150,6 +150,7 @@ files:
|
|
150
150
|
- lib/acts_as_list/active_record/acts/scope_method_definer.rb
|
151
151
|
- lib/acts_as_list/active_record/acts/sequential_updates_method_definer.rb
|
152
152
|
- lib/acts_as_list/active_record/acts/top_of_list_method_definer.rb
|
153
|
+
- lib/acts_as_list/active_record/acts/with_connection.rb
|
153
154
|
- lib/acts_as_list/version.rb
|
154
155
|
homepage: https://github.com/brendon/acts_as_list
|
155
156
|
licenses:
|
@@ -158,6 +159,7 @@ metadata:
|
|
158
159
|
changelog_uri: https://github.com/brendon/acts_as_list/blob/master/CHANGELOG.md
|
159
160
|
source_code_uri: https://github.com/brendon/acts_as_list
|
160
161
|
bug_tracker_uri: https://github.com/brendon/acts_as_list/issues
|
162
|
+
funding_uri: https://github.com/sponsors/brendon
|
161
163
|
rubygems_mfa_required: 'true'
|
162
164
|
post_install_message:
|
163
165
|
rdoc_options: []
|