arql 0.4.2 → 0.4.3

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: 80e79c3f9335368d2c09de3dca25191ebd3ee253c3d3792ff54823c30755b4a1
4
- data.tar.gz: a4afd1cfc77b594b88d6ca98baefd362fcad5f6613b7aa6d39d94c88fbcaf752
3
+ metadata.gz: 27b435e716bd7f2f1a9a806508fd4542887ed3a21ba02355ec0c1a5476cd3c0e
4
+ data.tar.gz: 59b8a4267407fcafe2df3714e785fd971cde979cc533802b33b3709ea2bc893d
5
5
  SHA512:
6
- metadata.gz: 3f558e44d5d1769d878bfee84e9d03f2fea71150377c0ecf5aa7f76970eb642bca1b4e96032fdb55bbbff645141fdd92fed104078d61cd03d672e6e548723741
7
- data.tar.gz: d4c022660f2ca90861e0f83d7a681e96feeb45500b0019bc2044401446e9fd551a5b0ee51b411222904d3732aa44a87f4427df812170f1013e730915d7dbeb5b
6
+ metadata.gz: 5493f7b368308e4e041c10f6562744bdb6ea47841959430c94e937b032f5d5fb44fbfc0d4217a9bc71b913fccdf70b4e23bd39f826bf47ec322a54223e2c34ab
7
+ data.tar.gz: b73fd3af4bcfbefe0502f5e7d44ad1dfcea63d22e906199550d3a432a0858769445d3d3d5e155e854e244e761616fe15e390e054306b24206aaf72abe13e2760
data/.vscode/launch.json CHANGED
@@ -6,12 +6,15 @@
6
6
  "configurations": [
7
7
  {
8
8
  "type": "rdbg",
9
- "name": "Debug current file with rdbg",
9
+ "name": "Debug Arql",
10
10
  "request": "launch",
11
11
  "script": "exe/arql",
12
12
  "command": "bundle exec",
13
13
  "useTerminal": true,
14
- "args": ["-e", "jicai.prod"],
14
+ "args": [
15
+ "-e",
16
+ "${input:env}"
17
+ ],
15
18
  "askParameters": false
16
19
  },
17
20
  {
@@ -19,5 +22,18 @@
19
22
  "name": "Attach with rdbg",
20
23
  "request": "attach"
21
24
  }
25
+ ],
26
+ "inputs": [
27
+ {
28
+ "id": "env",
29
+ "type": "command",
30
+ "command": "extension.commandvariable.pickStringRemember",
31
+ "args": {
32
+ "fileName": "${userHome}/.arql.d/init.yml",
33
+ "pattern": {
34
+ "regexp": "^([\\w\\.]+):.*"
35
+ }
36
+ }
37
+ }
22
38
  ]
23
39
  }
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- arql (0.4.2)
4
+ arql (0.4.3)
5
5
  activerecord (>= 6.1.5, < 7.1.0)
6
6
  activesupport (>= 6.1.5, < 7.1.0)
7
7
  caxlsx (~> 3.3.0)
@@ -17,6 +17,20 @@ module Arql
17
17
  }
18
18
  end.t
19
19
  end
20
+
21
+ define_singleton_method(:like) do |**args|
22
+ send(:ransack, "#{args.keys.first}_cont" => args.values.first).result
23
+ end
24
+
25
+ def self.method_missing(method_name, *args, &block)
26
+ if method_name.to_s =~ /^(.+)_like$/
27
+ attr_name = $1.to_sym
28
+ return super unless respond_to?(attr_name)
29
+ send(:like, $1 => args.first)
30
+ else
31
+ super
32
+ end
33
+ end
20
34
  end
21
35
 
22
36
  class Definition
@@ -0,0 +1,27 @@
1
+ module Ransack
2
+ module Adapters
3
+ module ActiveRecord
4
+ module Base
5
+ def ransack(params = {}, options = {})
6
+ old_base_connection = ::ActiveRecord::Base.method(:connection)
7
+ connection_obj = connection
8
+ ::ActiveRecord::Base.define_singleton_method(:connection) { connection_obj }
9
+ Search.new(self, params, options)
10
+ ensure
11
+ ::ActiveRecord::Base.define_singleton_method(:connection, old_base_connection)
12
+ end
13
+ end
14
+ end
15
+ end
16
+
17
+ class Search
18
+ def result(opts = {})
19
+ old_base_connection = ::ActiveRecord::Base.method(:connection)
20
+ connection_obj = @context.klass.connection
21
+ ::ActiveRecord::Base.define_singleton_method(:connection) { connection_obj }
22
+ @context.evaluate(self, opts)
23
+ ensure
24
+ ::ActiveRecord::Base.define_singleton_method(:connection, old_base_connection)
25
+ end
26
+ end
27
+ end
data/lib/arql/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Arql
2
- VERSION = "0.4.2"
2
+ VERSION = "0.4.3"
3
3
  end
data/lib/arql.rb CHANGED
@@ -19,6 +19,7 @@ require 'kaminari/activerecord'
19
19
  require 'composite_primary_keys'
20
20
  require 'ransack'
21
21
 
22
+ require 'arql/ext/active_record/base'
22
23
  require 'arql/ext/active_record/relation'
23
24
  require 'arql/ext/active_record/result'
24
25
  require 'arql/ext/ransack/search'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Liu Xiang
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-04-29 00:00:00.000000000 Z
11
+ date: 2024-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mysql2
@@ -340,6 +340,7 @@ files:
340
340
  - lib/arql/concerns/table_data_definition.rb
341
341
  - lib/arql/definition.rb
342
342
  - lib/arql/ext.rb
343
+ - lib/arql/ext/active_record/base.rb
343
344
  - lib/arql/ext/active_record/connection_adapters/abstract_mysql_adapter.rb
344
345
  - lib/arql/ext/active_record/connection_adapters/postgresql/schema_statements.rb
345
346
  - lib/arql/ext/active_record/relation.rb