active-query 0.2.0 → 0.2.1

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: 5636b341a804f0c3b2fb42b02b57ac502655c70c1cdc37c7e955004012375181
4
- data.tar.gz: 4e48fbc0f6877a05d963aca4aa04bac4cf2691111cc9857381428b3ff9998f22
3
+ metadata.gz: bafd618669b6562ca622703d0b758b27fdc2ea64d031569a44757db21230cb71
4
+ data.tar.gz: 35328a7159020c14d201d2735d8f364073418383819efcaad260be8e6911a83f
5
5
  SHA512:
6
- metadata.gz: b8c12b1ebe7b7317af9e2201d3cc6a6edc8cda475a2967e175f2e14605f273d87e1fe514045c3597396c7b5291ef83d6470212d41048af0c3a7ed7179b48df39
7
- data.tar.gz: ed6ba6312dcf12f8f83594ce2d0557466d495a7c901e351eff1490a641a8afcb9dda96f6885ae935e722ffca3738285b03cf2339380fc1a0c5edf451c8330b51
6
+ metadata.gz: f97020cced56e3f51ebb51c5c2844dafd408498d4a52b53722b542c9dfc5ae09e5838dede66601a01e0d6ccf1b8f764f1e6af791b416fd0d436103c0c494ff4a
7
+ data.tar.gz: 74ab0d6a7c1bb23475827832d87178112ff221f02dca5eb74b5a67703c4ec461f21e2499ed2deae15c09d609b63df7586ce6d8f5a124c8efb0e42c4bf63d0333
data/CHANGELOG.md CHANGED
@@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.2.1] - 2026-03-19
11
+
12
+ ### Added
13
+ - `ActiveQuery::Base.registry` — a global registry tracking all classes that include `ActiveQuery::Base`, enabling programmatic discovery of query objects in an application
14
+
15
+ ### Fixed
16
+ - Registry support for intermediary concern pattern (e.g. classes that include `ActiveQuery::Base` through an intermediate concern like `HireartQuery::Base`)
17
+ - Guard `infer_model` against anonymous classes with nil name
18
+
10
19
  ## [0.2.0] - 2026-03-11
11
20
 
12
21
  ### Added
@@ -50,7 +59,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
50
59
  - **Resolvers**: Support complex query logic with resolver classes
51
60
  - **Conditional Logic**: Apply scopes conditionally with `if`/`unless`
52
61
 
53
- [Unreleased]: https://github.com/matiasasis/active-query/compare/v0.2.0...HEAD
62
+ [Unreleased]: https://github.com/matiasasis/active-query/compare/v0.2.1...HEAD
63
+ [0.2.1]: https://github.com/matiasasis/active-query/compare/v0.2.0...v0.2.1
54
64
  [0.2.0]: https://github.com/matiasasis/active-query/compare/v0.1.3...v0.2.0
55
65
  [0.1.3]: https://github.com/matiasasis/active-query/compare/v0.0.1...v0.1.3
56
66
  [0.0.1]: https://github.com/matiasasis/active-query/releases/tag/v0.0.1
data/README.md CHANGED
@@ -11,6 +11,7 @@ ActiveQuery is a Ruby gem that helps you create clean, reusable query objects wi
11
11
  - **Conditional Logic**: Apply scopes conditionally with `if` and `unless`
12
12
  - **Resolver Pattern**: Support for complex query logic in separate classes
13
13
  - **Custom Scopes**: Define reusable scopes within query objects
14
+ - **Global Registry**: Discover all query objects in your application at runtime
14
15
  - **ActiveRecord Integration**: Works seamlessly with ActiveRecord models
15
16
 
16
17
  ## Installation
@@ -326,6 +327,44 @@ UserQuery.queries
326
327
  # ]
327
328
  ```
328
329
 
330
+ ### Global Query Registry
331
+
332
+ `ActiveQuery::Base` maintains a global registry of all classes that include it, enabling programmatic discovery of every query object in your application:
333
+
334
+ ```ruby
335
+ # All query objects are automatically registered
336
+ class UserQuery
337
+ include ActiveQuery::Base
338
+ # ...
339
+ end
340
+
341
+ class ProductQuery
342
+ include ActiveQuery::Base
343
+ # ...
344
+ end
345
+
346
+ # Discover all registered query objects
347
+ ActiveQuery::Base.registry
348
+ # => [UserQuery, ProductQuery]
349
+ ```
350
+
351
+ This also works when including `ActiveQuery::Base` through an intermediary concern:
352
+
353
+ ```ruby
354
+ module ApplicationQuery
355
+ extend ActiveSupport::Concern
356
+ include ActiveQuery::Base
357
+ end
358
+
359
+ class OrderQuery
360
+ include ApplicationQuery
361
+ # ...
362
+ end
363
+
364
+ ActiveQuery::Base.registry
365
+ # => [..., OrderQuery]
366
+ ```
367
+
329
368
  ### Error Handling
330
369
 
331
370
  ActiveQuery provides clear error messages for common mistakes:
data/active-query.gemspec CHANGED
@@ -7,7 +7,6 @@ Gem::Specification.new do |spec|
7
7
  spec.version = ActiveQuery::VERSION
8
8
  spec.authors = ["Matias Asis"]
9
9
  spec.email = ["matiasis.90@gmail.com"]
10
-
11
10
  spec.summary = "ActiveQuery is a gem that helps you to create query objects in a simple way."
12
11
  spec.description = "ActiveQuery is a gem that helps you to create query objects in a simple way. It provides a DSL to define queries and scopes for your query object."
13
12
  spec.homepage = "https://github.com/matiasasis/active-query"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveQuery
4
- VERSION = '0.2.0'
4
+ VERSION = '0.2.1'
5
5
  end
data/lib/active_query.rb CHANGED
@@ -14,7 +14,14 @@ module ActiveQuery
14
14
 
15
15
  Boolean = ActiveQuery::Types::Boolean
16
16
 
17
+ @registry = []
18
+
19
+ def self.registry
20
+ @registry
21
+ end
22
+
17
23
  included do
24
+ ActiveQuery::Base.registry << self unless ActiveQuery::Base.registry.include?(self)
18
25
  infer_model
19
26
  @__queries = []
20
27
  end
@@ -73,6 +80,8 @@ module ActiveQuery
73
80
  end
74
81
 
75
82
  def infer_model
83
+ return unless self.name
84
+
76
85
  model_class_name = self.name.sub(/::Query$/, '').classify
77
86
  return unless const_defined?(model_class_name)
78
87
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active-query
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matias Asis