activerecord-text-search-configuration 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 570691dfaa883e86226e49e9c62be2ce9c5f1b6fa374db9ebb531bb39df5fcfa
|
|
4
|
+
data.tar.gz: 1dbb5918dbe51d9f04c219dd8b54e6bcce88057f590c948dd36043c1f5418bbb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6fba43c0aa8ab8c4963b2f335d291bcf6d8f53ffa7f1564d8623f3901bd6a590601579468dde104bc29e608756229b45cbb1b3b9304ad70bf3c9b90c9bce57b6
|
|
7
|
+
data.tar.gz: fa2834e91e64f28368e79fb653520a4ec7e50df63caba16f93969542b117c8dadacb7f6c9011c8090634c4714c4590b05a1f0f96647d899be5a45227008fbd1f
|
|
@@ -4,25 +4,26 @@ module ActiveRecord
|
|
|
4
4
|
module TextSearchConfiguration
|
|
5
5
|
# Records text search configuration statements in migrations so they can be reverted.
|
|
6
6
|
module CommandRecorder
|
|
7
|
-
def create_text_search_configuration(*args, &)
|
|
8
|
-
|
|
7
|
+
def create_text_search_configuration(*args, **kwargs, &)
|
|
8
|
+
command = text_search_configuration_command(__method__, args, kwargs)
|
|
9
|
+
record(*command, &)
|
|
9
10
|
end
|
|
10
11
|
|
|
11
|
-
def drop_text_search_configuration(*args, &)
|
|
12
|
-
|
|
12
|
+
def drop_text_search_configuration(*args, **kwargs, &)
|
|
13
|
+
command = text_search_configuration_command(__method__, args, kwargs)
|
|
14
|
+
record(*command, &)
|
|
13
15
|
end
|
|
14
16
|
|
|
15
17
|
private
|
|
16
18
|
|
|
17
|
-
def invert_create_text_search_configuration(args)
|
|
18
|
-
|
|
19
|
+
def invert_create_text_search_configuration(args, _kwargs = nil)
|
|
20
|
+
text_search_configuration_command(:drop_text_search_configuration, [args.first], {})
|
|
19
21
|
end
|
|
20
22
|
|
|
21
23
|
# Dropping can only be reverted when the migration passes everything needed to create the
|
|
22
24
|
# configuration again.
|
|
23
|
-
def invert_drop_text_search_configuration(args)
|
|
24
|
-
|
|
25
|
-
if options[:parser].nil? && options[:copy].nil?
|
|
25
|
+
def invert_drop_text_search_configuration(args, kwargs = args.extract_options!)
|
|
26
|
+
if kwargs[:parser].nil? && kwargs[:copy].nil?
|
|
26
27
|
raise(
|
|
27
28
|
ActiveRecord::IrreversibleMigration,
|
|
28
29
|
'To make drop_text_search_configuration reversible, pass parser: or copy: and ' \
|
|
@@ -30,7 +31,18 @@ module ActiveRecord
|
|
|
30
31
|
)
|
|
31
32
|
end
|
|
32
33
|
|
|
33
|
-
|
|
34
|
+
text_search_configuration_command(
|
|
35
|
+
:create_text_search_configuration, [args.first], kwargs.except(:if_exists, :force)
|
|
36
|
+
)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Rails 8.2 takes three instead of two arguments to the methods, this is an adapter so the
|
|
40
|
+
# code works on older and newer versions of Rails.
|
|
41
|
+
def text_search_configuration_command(command, args, kwargs)
|
|
42
|
+
return [command, args, kwargs] if method(:record).arity == 3
|
|
43
|
+
return [command, args] if kwargs.empty?
|
|
44
|
+
|
|
45
|
+
[command, [*args, Hash.ruby2_keywords_hash(kwargs)]]
|
|
34
46
|
end
|
|
35
47
|
end
|
|
36
48
|
end
|