activerecord-hashlike_access 0.1.1 → 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 +4 -4
- data/.rubocop.yml +2 -9
- data/.yardopts +4 -3
- data/CHANGELOG.md +18 -3
- data/Gemfile.lock +2 -2
- data/README.md +13 -2
- data/activerecord-hashlike_access.gemspec +29 -23
- data/docs/ActiveRecord/HashlikeAccess.html +805 -0
- data/docs/ActiveRecord.html +120 -0
- data/docs/_index.html +111 -0
- data/docs/class_list.html +54 -0
- data/docs/css/common.css +1 -0
- data/docs/css/full_list.css +206 -0
- data/docs/css/style.css +1089 -0
- data/docs/file.README.html +291 -0
- data/docs/file_list.html +59 -0
- data/docs/frames.html +22 -0
- data/docs/index.html +291 -0
- data/docs/js/app.js +801 -0
- data/docs/js/full_list.js +334 -0
- data/docs/js/jquery.js +4 -0
- data/docs/method_list.html +102 -0
- data/docs/top-level-namespace.html +102 -0
- data/lib/active_record/hashlike_access/auto_extend.rb +9 -0
- data/lib/active_record/hashlike_access/version.rb +1 -1
- metadata +22 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: de5302f3fccb412e6b30307a7bbcdc52b0da026d5ad3f52e081704220c89460a
|
|
4
|
+
data.tar.gz: 8935894c2b82672909f976ddfed9552a0fd74aec52dcb9383b93d7d8f15020fa
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fa22e231e8b3cf1e7448efc34d603ca9d65268d2f4189a0949367cbec95bd025ac0e443e164064dcd13f2d7fbd4fe0aff29f20d9a5eb82664230a6b145e1bae9
|
|
7
|
+
data.tar.gz: a9e954fb464a8a9bcda75d684e5bb6242a4218b94ea2a63e2d49077171d30bf7f70bcfbce5647421ddb4fe27cf4ebbef547f6b579e13dcb236848eba7d586695
|
data/.rubocop.yml
CHANGED
|
@@ -35,16 +35,9 @@ Metrics/MethodLength:
|
|
|
35
35
|
|
|
36
36
|
Naming/VariableNumber:
|
|
37
37
|
# Use the configured style when numbering symbols, methods and variables.
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
Exclude:
|
|
39
|
+
- spec/**/*
|
|
40
40
|
|
|
41
|
-
Style/AsciiComments:
|
|
42
|
-
# Use only ASCII symbols in comments.
|
|
43
|
-
#
|
|
44
|
-
# NLC: We're allowing non-breaking spaces (' '), as they're needed to prevent
|
|
45
|
-
# browsers from collapsing multiple spaces in documentation code blocks.
|
|
46
|
-
AllowedChars:
|
|
47
|
-
- ' '
|
|
48
41
|
|
|
49
42
|
Style/FormatString:
|
|
50
43
|
# Enforce the use of Kernel#sprintf, Kernel#format or String#%.
|
data/.yardopts
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
# Changelog
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## v0.2.1 (2026-09-29)
|
|
4
|
+
- **Documentation**:
|
|
5
|
+
- Removed `ActiveRecord::Base` from the class list.
|
|
6
|
+
- Added gem version badge to README.
|
|
7
|
+
- Added full documentation link to README.
|
|
8
|
+
- **Chores**:
|
|
9
|
+
- Corrected typos in Gemspec URIs.
|
|
4
10
|
|
|
5
|
-
|
|
11
|
+
## v0.2.0 (2026-08-18)
|
|
12
|
+
- **Features**: Added a `require` entrypoint that provides hash-like access to all models.
|
|
13
|
+
|
|
14
|
+
## v0.1.1 (2026-08-18)
|
|
15
|
+
- **Chores**: Patch-bump to correct release version.
|
|
16
|
+
|
|
17
|
+
## v0.1.0 (2026-08-18)
|
|
18
|
+
(Note this was incorrectly released as version `0.0.0`.)
|
|
19
|
+
- **Features**: Initial "hash-like access" implementation.
|
|
20
|
+
- **Testing**: Proper testing of all expected behaviors.
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
activerecord-hashlike_access (0.
|
|
4
|
+
activerecord-hashlike_access (0.2.0)
|
|
5
5
|
activerecord (>= 6)
|
|
6
6
|
|
|
7
7
|
GEM
|
|
@@ -145,7 +145,7 @@ DEPENDENCIES
|
|
|
145
145
|
CHECKSUMS
|
|
146
146
|
activemodel (8.1.3.1) sha256=99cc02ce2faec371d14440949d85787ebd23a907c9baef0a9d4bcd4d21888f88
|
|
147
147
|
activerecord (8.1.3.1) sha256=0a2fb6c28f4938f6b013a3a549bec0a7e37d535f3dc8990e804bcc3258c0403b
|
|
148
|
-
activerecord-hashlike_access (0.
|
|
148
|
+
activerecord-hashlike_access (0.2.0)
|
|
149
149
|
activesupport (8.1.3.1) sha256=85458765f25ea48b9019c46b6bb3fa5683197bf4280d9f06710a6e8d7a831376
|
|
150
150
|
ast (2.4.3) sha256=954615157c1d6a382bc27d690d973195e79db7f55e9765ac7c481c60bdb4d383
|
|
151
151
|
base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b
|
data/README.md
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
[](https://rubygems.org/gems/activerecord-hashlike_access)
|
|
1
2
|
[](https://tldrlegal.com/license/mit-license)
|
|
2
3
|
|
|
3
4
|
|
|
@@ -42,13 +43,23 @@ Role[name] = new_display_text
|
|
|
42
43
|
|
|
43
44
|
Importantly, note that **this gem works on the model, not its relations**. ActiveRecord's existing bracket constructs for referencing _relations_ (i.e. resultsets) in an `Array`-like fashion will continue to work as they always have.
|
|
44
45
|
|
|
46
|
+
[Full documentation is available here](https://nestor-custodio.github.io/activerecord-hashlike_access/ActiveRecord/HashlikeAccess.html), but do read below for a crash course on availble featues!
|
|
47
|
+
|
|
45
48
|
|
|
46
49
|
## Installation
|
|
47
50
|
|
|
48
51
|
- If your project uses [Bundler](https://github.com/bundler/bundler):
|
|
49
|
-
- Add the following to your application's Gemfile:
|
|
52
|
+
- Add one of the following to your application's Gemfile:
|
|
50
53
|
```ruby
|
|
54
|
+
# For on-demand usage:
|
|
55
|
+
|
|
51
56
|
gem 'activerecord-hashlike_access'
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
# To automatically `extend ActiveRecord::HashlikeAccess`
|
|
60
|
+
# into all your (`ActiveRecord::Base`-descended) models:
|
|
61
|
+
|
|
62
|
+
gem 'activerecord-hashlike_access', require: 'active_record/hashlike_access/auto_extend'
|
|
52
63
|
```
|
|
53
64
|
- And then run a:
|
|
54
65
|
```shell
|
|
@@ -220,7 +231,7 @@ Every instance of a hash-like lookup (`[some_key]`) is backed by a `find_by`/`fi
|
|
|
220
231
|
|
|
221
232
|
## Potential Gotchas
|
|
222
233
|
|
|
223
|
-
As with anything ActiveRecord-related, there are
|
|
234
|
+
As with anything ActiveRecord-related, there are ways to shoot yourself in the foot if you're not careful. Here are a few items to keep in mind and hopefully prevent this:
|
|
224
235
|
|
|
225
236
|
- The hash-like access construct is essentially syntax sugar around ActiveRecord's `find_by` mechanism. For many (most?) database engines, selecting (or _including_, in the case of a multi-field key) an unindexed field for your lookups will likely result in a full-table scan with every hash-like access. Be mindful of what field(s) you're using as your key(s).
|
|
226
237
|
|
|
@@ -1,33 +1,39 @@
|
|
|
1
1
|
require_relative 'lib/active_record/hashlike_access/version'
|
|
2
2
|
|
|
3
3
|
Gem::Specification.new do |spec|
|
|
4
|
-
spec.name = 'activerecord-hashlike_access'
|
|
5
|
-
spec.version = ActiveRecord::HashlikeAccess::VERSION
|
|
6
|
-
spec.authors = ['Nestor Custodio']
|
|
7
|
-
spec.email = ['nestor@custodio.org']
|
|
8
|
-
|
|
9
|
-
spec.summary = 'Provides Hash-like access to ActiveRecord models.'
|
|
10
|
-
spec.homepage = 'https://github.com/nestor-custodio/activerecord-hashlike_acces'
|
|
11
|
-
spec.license = 'MIT'
|
|
12
4
|
spec.required_ruby_version = '>= 3.4'
|
|
13
5
|
|
|
14
|
-
spec.
|
|
15
|
-
|
|
16
|
-
spec.
|
|
17
|
-
spec.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
spec.bindir = 'exe'
|
|
28
|
-
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
|
6
|
+
spec.name = 'activerecord-hashlike_access'
|
|
7
|
+
spec.version = ActiveRecord::HashlikeAccess::VERSION
|
|
8
|
+
spec.authors = ['Nestor Custodio']
|
|
9
|
+
spec.email = ['nestor@custodio.org']
|
|
10
|
+
|
|
11
|
+
spec.summary = 'Provides Hash-like access to ActiveRecord models.'
|
|
12
|
+
spec.homepage = 'https://github.com/nestor-custodio/activerecord-hashlike_access'
|
|
13
|
+
spec.license = 'MIT'
|
|
14
|
+
|
|
15
|
+
spec.files = `git ls-files -z`.split("\x0") - Dir['.[!.]*/**/*', 'bin/**/*', 'spec/**/*', '.git*']
|
|
16
|
+
spec.executables = []
|
|
29
17
|
spec.require_paths = ['lib']
|
|
30
18
|
|
|
19
|
+
# ---
|
|
20
|
+
|
|
21
|
+
spec.metadata = {
|
|
22
|
+
# See: https://guides.rubygems.org/specification-reference/#metadata
|
|
23
|
+
|
|
24
|
+
# RubyGems.org Security
|
|
25
|
+
#
|
|
26
|
+
'allowed_push_host' => 'https://rubygems.org',
|
|
27
|
+
'rubygems_mfa_required' => 'true',
|
|
28
|
+
|
|
29
|
+
# Metadata-Provided URIs
|
|
30
|
+
#
|
|
31
|
+
'homepage_uri' => spec.homepage,
|
|
32
|
+
'changelog_uri' => "#{spec.homepage}/CHANGELOG.md"
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
# ---
|
|
36
|
+
|
|
31
37
|
# This of course requires ActiveRecord.
|
|
32
38
|
#
|
|
33
39
|
spec.add_dependency 'activerecord', '>= 6'
|