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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 25fc3d615fa4c5dec3f58db1b116a2f1affc0d6ceb896b19a4c14c21fea7d485
4
- data.tar.gz: 78545089eba9bb3a807f6cadaebe8f4c39f7c80c3f887f1f79042db5383feca2
3
+ metadata.gz: de5302f3fccb412e6b30307a7bbcdc52b0da026d5ad3f52e081704220c89460a
4
+ data.tar.gz: 8935894c2b82672909f976ddfed9552a0fd74aec52dcb9383b93d7d8f15020fa
5
5
  SHA512:
6
- metadata.gz: 0e0f4b79e1bfd1f1ba58c153e5d7181ef399cf5866087d30b15283ff013f3f12a90897238eecab8f74fbdec7785ec5aef19f37f673315063a4b0f581ca821e20
7
- data.tar.gz: 3c8d30c4917cde11adcc4b81041c764ce3967f0a6a7b8f1e366a60e77b6808f4883b098a95deef89709b220be86910e88842af0fb5d751f0f90dcb5ffad31ae4
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
- Enabled: false
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
@@ -1,4 +1,5 @@
1
- --format=html
2
- --markup=markdown
3
- --output-dir=./docs
1
+ --format='html'
2
+ --markup='markdown'
3
+ --output-dir='./docs'
4
4
  --private
5
+ --query='!@api || (@api.text != "entrypoint")'
data/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
- ## [Unreleased]
1
+ # Changelog
2
2
 
3
- ## [0.0.0] - 2026-08-06
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
- - Initial release.
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.1.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.1.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
+ [![Gem Version](https://img.shields.io/github/v/release/nestor-custodio/activerecord-hashlike_access?color=green&label=gem%20version)](https://rubygems.org/gems/activerecord-hashlike_access)
1
2
  [![MIT License](https://img.shields.io/github/license/nestor-custodio/activerecord-hashlike_access)](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 always several 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:
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.metadata['allowed_push_host'] = 'https://rubygems.org'
15
-
16
- spec.metadata['homepage_uri'] = spec.homepage
17
- spec.metadata['changelog_uri'] = "#{spec.homepage}/CHANGELOG.md"
18
- spec.metadata['rubygems_mfa_required'] = 'true'
19
-
20
- # Specify which files should be added to the gem when it is released.
21
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
- spec.files = Dir.chdir(__dir__) do
23
- `git ls-files -z`.split("\x0").reject do |f|
24
- (File.expand_path(f) == __FILE__) || f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor])
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'