inquiry_attrs 1.0.0 → 1.0.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 +4 -4
- data/CHANGELOG.md +79 -6
- data/README.md +7 -0
- data/lib/inquiry_attrs/railtie.rb +1 -1
- data/lib/inquiry_attrs/version.rb +1 -1
- metadata +24 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e38ba51363664abde16b95c0369e6c81a59d5328a5040a3ae16f6b90ebc89fca
|
|
4
|
+
data.tar.gz: 8f90df1580bff8741d69d5654b16cf35ca81f5a31167a3a89563ebec7f2c4b10
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fc6265f245d6f36cba27d4f98f82e0e2778eccf657c0ea549ab46519db81fe7865a6f3c552f8a293b11bfd434124b04552f82698bacf0950750c31d01735b1b8
|
|
7
|
+
data.tar.gz: a9acf7294f8d6c55fe5dd5ab36871d9e5b35355665888276d875ab0fd6e3a330067e6c00544b0a4a61a1f23052e5a96b59377721c3b63e7580af5b2f9efcac37
|
data/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,84 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
All notable changes to `inquiry_attrs` are documented in this file.
|
|
4
|
+
|
|
5
|
+
The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
6
|
+
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## [Unreleased]
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
3
14
|
## [1.0.0] — 2026-02-27
|
|
4
15
|
|
|
5
16
|
### Added
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
-
|
|
10
|
-
|
|
11
|
-
|
|
17
|
+
|
|
18
|
+
#### Core
|
|
19
|
+
|
|
20
|
+
- **`InquiryAttrs::Concern`** — `ActiveSupport::Concern` that adds the
|
|
21
|
+
`.inquirer(*attrs)` class macro to any model. Automatically included into
|
|
22
|
+
`ActiveRecord::Base` via the generated initializer; opt-in for StoreModel
|
|
23
|
+
and plain Ruby classes via explicit `include`.
|
|
24
|
+
|
|
25
|
+
- **`InquiryAttrs::NilInquiry`** — frozen singleton (`INSTANCE`) returned when
|
|
26
|
+
an inquired attribute is blank. Every `?`-predicate returns `false`; behaves
|
|
27
|
+
like `nil` in comparisons (`== nil`, `== ""`). Eliminates `NoMethodError` on
|
|
28
|
+
nil attributes.
|
|
29
|
+
|
|
30
|
+
- **`InquiryAttrs::SymbolInquiry`** — `SimpleDelegator` subclass returned when
|
|
31
|
+
an inquired attribute holds a `Symbol`. Predicate methods match against the
|
|
32
|
+
symbol name; compares equal to both `Symbol` and `String`; `is_a?(Symbol)`
|
|
33
|
+
returns `true`.
|
|
34
|
+
|
|
35
|
+
- **Return-type dispatch in `.inquirer`** — blank → `NilInquiry::INSTANCE`,
|
|
36
|
+
Symbol → `SymbolInquiry`, anything else → `ActiveSupport::StringInquirer`
|
|
37
|
+
(standard `"value".inquiry`).
|
|
38
|
+
|
|
39
|
+
- **`instance_method` capture pattern** — the original attribute reader is
|
|
40
|
+
captured with `instance_method(attr)` and called via `bind_call` inside the
|
|
41
|
+
wrapper, so `attr_accessor`, StoreModel, and AR readers all work without
|
|
42
|
+
relying on `super()`.
|
|
43
|
+
|
|
44
|
+
- **`remove_method` before `define_method`** — clears the reader from the
|
|
45
|
+
class's own method table before redefining, silencing Ruby's "method
|
|
46
|
+
redefined" warning that fires when AR/StoreModel define readers via
|
|
47
|
+
`define_method` and `inquirer` overwrites them.
|
|
48
|
+
|
|
49
|
+
#### Install task
|
|
50
|
+
|
|
51
|
+
- **`InquiryAttrs::Installer`** — pure Ruby class with `install!(rails_root)`
|
|
52
|
+
and `uninstall!(rails_root)` class methods. Accepts `Pathname` or `String`.
|
|
53
|
+
Returns `:created` / `:skipped` / `:removed` symbols. Testable without Rails
|
|
54
|
+
or Rake by passing a `Dir.mktmpdir` path.
|
|
55
|
+
|
|
56
|
+
- **`InquiryAttrs::Railtie`** — loaded when `Rails::Railtie` is defined;
|
|
57
|
+
exposes `rails inquiry_attrs:install` and `rails inquiry_attrs:uninstall` to
|
|
58
|
+
the host application via `rake_tasks { load ... }`.
|
|
59
|
+
|
|
60
|
+
- **`rails inquiry_attrs:install`** — writes
|
|
61
|
+
`config/initializers/inquiry_attrs.rb` containing the
|
|
62
|
+
`ActiveSupport.on_load(:active_record)` block. Skips silently if the file
|
|
63
|
+
already exists.
|
|
64
|
+
|
|
65
|
+
- **`rails inquiry_attrs:uninstall`** — removes the generated initializer.
|
|
66
|
+
Skips silently if the file is absent.
|
|
67
|
+
|
|
68
|
+
#### Developer experience
|
|
69
|
+
|
|
70
|
+
- **`Rakefile`** — `bundle exec rake` / `bundle exec rake test` runs the full
|
|
71
|
+
Minitest suite.
|
|
72
|
+
|
|
73
|
+
- **LLM context** — `AGENTS.md`, `CLAUDE.md`, `llms/overview.md`,
|
|
74
|
+
`llms/usage.md` shipped inside the gem for AI-assisted development.
|
|
75
|
+
|
|
76
|
+
### Compatibility
|
|
77
|
+
|
|
78
|
+
- Ruby ≥ 3.0
|
|
79
|
+
- Rails 7.x and 8.x (`activesupport`, `activerecord`, `railties` — `>= 7.0, < 9`)
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
[Unreleased]: https://github.com/pniemczyk/inquiry_attrs/compare/v1.0.0...HEAD
|
|
84
|
+
[1.0.0]: https://github.com/pniemczyk/inquiry_attrs/releases/tag/v1.0.0
|
data/README.md
CHANGED
|
@@ -34,6 +34,13 @@ gem 'inquiry_attrs'
|
|
|
34
34
|
|
|
35
35
|
### ActiveRecord — zero configuration
|
|
36
36
|
|
|
37
|
+
Use rake task to install or uninstall the initializer:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
rails inquiry_attrs:install # Install an initializer that auto-includes InquiryAttrs::Concern into ActiveRecord
|
|
41
|
+
rails inquiry_attrs:uninstall # Remove the inquiry_attrs initializer
|
|
42
|
+
```
|
|
43
|
+
|
|
37
44
|
`inquiry_attrs` auto-includes itself into every `ActiveRecord::Base` subclass
|
|
38
45
|
via `ActiveSupport.on_load(:active_record)`. Just call `.inquirer` in any model:
|
|
39
46
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: inquiry_attrs
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Pawel Niemczyk
|
|
@@ -16,6 +16,9 @@ dependencies:
|
|
|
16
16
|
- - ">="
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
18
|
version: '7.0'
|
|
19
|
+
- - "<"
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: '9'
|
|
19
22
|
type: :runtime
|
|
20
23
|
prerelease: false
|
|
21
24
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -23,6 +26,9 @@ dependencies:
|
|
|
23
26
|
- - ">="
|
|
24
27
|
- !ruby/object:Gem::Version
|
|
25
28
|
version: '7.0'
|
|
29
|
+
- - "<"
|
|
30
|
+
- !ruby/object:Gem::Version
|
|
31
|
+
version: '9'
|
|
26
32
|
- !ruby/object:Gem::Dependency
|
|
27
33
|
name: activerecord
|
|
28
34
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -30,6 +36,9 @@ dependencies:
|
|
|
30
36
|
- - ">="
|
|
31
37
|
- !ruby/object:Gem::Version
|
|
32
38
|
version: '7.0'
|
|
39
|
+
- - "<"
|
|
40
|
+
- !ruby/object:Gem::Version
|
|
41
|
+
version: '9'
|
|
33
42
|
type: :runtime
|
|
34
43
|
prerelease: false
|
|
35
44
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -37,6 +46,9 @@ dependencies:
|
|
|
37
46
|
- - ">="
|
|
38
47
|
- !ruby/object:Gem::Version
|
|
39
48
|
version: '7.0'
|
|
49
|
+
- - "<"
|
|
50
|
+
- !ruby/object:Gem::Version
|
|
51
|
+
version: '9'
|
|
40
52
|
- !ruby/object:Gem::Dependency
|
|
41
53
|
name: railties
|
|
42
54
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -44,6 +56,9 @@ dependencies:
|
|
|
44
56
|
- - ">="
|
|
45
57
|
- !ruby/object:Gem::Version
|
|
46
58
|
version: '7.0'
|
|
59
|
+
- - "<"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '9'
|
|
47
62
|
type: :runtime
|
|
48
63
|
prerelease: false
|
|
49
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -51,6 +66,9 @@ dependencies:
|
|
|
51
66
|
- - ">="
|
|
52
67
|
- !ruby/object:Gem::Version
|
|
53
68
|
version: '7.0'
|
|
69
|
+
- - "<"
|
|
70
|
+
- !ruby/object:Gem::Version
|
|
71
|
+
version: '9'
|
|
54
72
|
description: |
|
|
55
73
|
InquiryAttrs wraps ActiveRecord/ActiveModel (and StoreModel/Dry::Struct) attributes with
|
|
56
74
|
predicate-style inquiry methods. Write user.status.active? instead of
|
|
@@ -58,7 +76,8 @@ description: |
|
|
|
58
76
|
predicate — no more NoMethodError on nil. Run `rails inquiry_attrs:install`
|
|
59
77
|
to generate an initializer that auto-includes the concern into every
|
|
60
78
|
ActiveRecord model.
|
|
61
|
-
email:
|
|
79
|
+
email:
|
|
80
|
+
- pniemczyk.info@gmail.com
|
|
62
81
|
executables: []
|
|
63
82
|
extensions: []
|
|
64
83
|
extra_rdoc_files: []
|
|
@@ -78,13 +97,12 @@ files:
|
|
|
78
97
|
- lib/tasks/inquiry_attrs.rake
|
|
79
98
|
- llms/overview.md
|
|
80
99
|
- llms/usage.md
|
|
81
|
-
homepage: https://github.com/
|
|
100
|
+
homepage: https://github.com/pniemczyk/inquiry_attrs
|
|
82
101
|
licenses:
|
|
83
102
|
- MIT
|
|
84
103
|
metadata:
|
|
85
|
-
homepage_uri: https://github.com/
|
|
86
|
-
|
|
87
|
-
changelog_uri: https://github.com/your-org/inquiry_attrs/blob/main/CHANGELOG.md
|
|
104
|
+
homepage_uri: https://github.com/pniemczyk/inquiry_attrs
|
|
105
|
+
changelog_uri: https://github.com/pniemczyk/inquiry_attrs/blob/main/CHANGELOG.md
|
|
88
106
|
rdoc_options: []
|
|
89
107
|
require_paths:
|
|
90
108
|
- lib
|