safe_polymorphic 0.1.1 → 0.1.2
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 +5 -1
- data/Gemfile.lock +1 -1
- data/README.md +3 -3
- data/{config → lib/safe_polymorphic}/locales/en.yml +0 -0
- data/lib/safe_polymorphic/version.rb +1 -1
- data/lib/safe_polymorphic.rb +4 -2
- data/safe_polymorphic.gemspec +4 -2
- metadata +8 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 164e389f0104c35deef618728e27279f0f1efb563398cec61c4c4c6611972f1b
|
4
|
+
data.tar.gz: 9ee365c0242b60164baac2f00f338334f99c73b96e661eea11ffd3f60aa225d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9f0e945aeabcf77b7cf35b7b491df63dc97e86fa0d30500d31b2424880bb42543b0310f8f1840e8a9dbab57088292670e36097e7e3c2be7f0b32959299e3074
|
7
|
+
data.tar.gz: 1c64d72005b5c64007a00286bca4ca9bab89753efff0636c33d5b1e103af5f3d5465ec777d87033eabf8372a38372a2973b7b57c6353f8d252d374eb64bab345
|
data/CHANGELOG.md
CHANGED
@@ -7,4 +7,8 @@
|
|
7
7
|
|
8
8
|
## [0.1.1] - 2022-12-28
|
9
9
|
|
10
|
-
- Fix finder method bug when searching using an instance of a class
|
10
|
+
- Fix finder method bug when searching using an instance of a class
|
11
|
+
|
12
|
+
## [0.1.2] - 2022-12-28
|
13
|
+
|
14
|
+
- Fix issue that forced to declare the I18n locale (`class_not_allowed`) in each project using this gem instead of using the default locale included in the gem
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
[](https://codeclimate.com/github/gogrow-dev/safe_polymorphic/maintainability)
|
5
5
|
[](https://codeclimate.com/github/gogrow-dev/safe_polymorphic/test_coverage)
|
6
6
|
|
7
|
-
|
7
|
+
ActiveRecord extension which allows us to safely use polymorphic associations, by validating which classes are allowed to be related to, while also adding scopes and helper methods.
|
8
8
|
|
9
9
|
The base idea was taken from this blogpost: [Improve ActiveRecord Polymorphic Associations - Head of engineering at Product Hunt](https://blog.rstankov.com/allowed-class-names-in-activerecord-polymorphic-associations/).
|
10
10
|
|
@@ -89,11 +89,11 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
89
89
|
|
90
90
|
## Contributing
|
91
91
|
|
92
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
92
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/gogrow-dev/safe_polymorphic. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/gogrow-dev/safe_polymorphic/blob/main/CODE_OF_CONDUCT.md).
|
93
93
|
|
94
94
|
## Code of Conduct
|
95
95
|
|
96
|
-
Everyone interacting in the SafePolymorphic project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
96
|
+
Everyone interacting in the SafePolymorphic project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/gogrow-dev/safe_polymorphic/blob/main/CODE_OF_CONDUCT.md).
|
97
97
|
|
98
98
|
## Credits
|
99
99
|
|
File without changes
|
data/lib/safe_polymorphic.rb
CHANGED
@@ -4,11 +4,13 @@ require_relative 'safe_polymorphic/version'
|
|
4
4
|
require 'active_record'
|
5
5
|
require_relative 'safe_polymorphic/associations'
|
6
6
|
|
7
|
-
I18n.load_path << File.expand_path('config/locales/en.yml')
|
8
|
-
|
9
7
|
module SafePolymorphic
|
10
8
|
class Error < StandardError; end
|
11
9
|
end
|
12
10
|
|
11
|
+
ActiveSupport.on_load(:i18n) do
|
12
|
+
I18n.load_path << File.expand_path('safe_polymorphic/locales/en.yml', __dir__)
|
13
|
+
end
|
14
|
+
|
13
15
|
# Extend ActiveRecord::Base with belongs to polymorphic associations
|
14
16
|
ActiveRecord::Base.include SafePolymorphic::Associations
|
data/safe_polymorphic.gemspec
CHANGED
@@ -9,14 +9,16 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ['Nicolas Erlichman']
|
10
10
|
spec.email = ['nicolas@gogrow.dev']
|
11
11
|
|
12
|
-
spec.summary = '
|
13
|
-
'
|
12
|
+
spec.summary = 'Safely use polymorphic associations by validating which classes are allowed to be related to.'
|
13
|
+
spec.description = 'ActiveRecord extension which allows us to safely use polymorphic associations, by validating' \
|
14
|
+
'which classes are allowed to be related to, while also adding scopes and helper methods.'
|
14
15
|
spec.homepage = 'https://github.com/gogrow-dev/safe_polymorphic'
|
15
16
|
spec.required_ruby_version = '>= 2.6.0'
|
16
17
|
|
17
18
|
spec.metadata['homepage_uri'] = spec.homepage
|
18
19
|
spec.metadata['source_code_uri'] = spec.homepage
|
19
20
|
spec.metadata['changelog_uri'] = "#{spec.homepage}/blob/master/CHANGELOG.md"
|
21
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
20
22
|
|
21
23
|
# Specify which files should be added to the gem when it is released.
|
22
24
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: safe_polymorphic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicolas Erlichman
|
@@ -30,7 +30,9 @@ dependencies:
|
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '7.1'
|
33
|
-
description:
|
33
|
+
description: ActiveRecord extension which allows us to safely use polymorphic associations,
|
34
|
+
by validatingwhich classes are allowed to be related to, while also adding scopes
|
35
|
+
and helper methods.
|
34
36
|
email:
|
35
37
|
- nicolas@gogrow.dev
|
36
38
|
executables: []
|
@@ -46,9 +48,9 @@ files:
|
|
46
48
|
- LICENSE.md
|
47
49
|
- README.md
|
48
50
|
- Rakefile
|
49
|
-
- config/locales/en.yml
|
50
51
|
- lib/safe_polymorphic.rb
|
51
52
|
- lib/safe_polymorphic/associations.rb
|
53
|
+
- lib/safe_polymorphic/locales/en.yml
|
52
54
|
- lib/safe_polymorphic/version.rb
|
53
55
|
- safe_polymorphic.gemspec
|
54
56
|
homepage: https://github.com/gogrow-dev/safe_polymorphic
|
@@ -58,6 +60,7 @@ metadata:
|
|
58
60
|
homepage_uri: https://github.com/gogrow-dev/safe_polymorphic
|
59
61
|
source_code_uri: https://github.com/gogrow-dev/safe_polymorphic
|
60
62
|
changelog_uri: https://github.com/gogrow-dev/safe_polymorphic/blob/master/CHANGELOG.md
|
63
|
+
rubygems_mfa_required: 'true'
|
61
64
|
post_install_message:
|
62
65
|
rdoc_options: []
|
63
66
|
require_paths:
|
@@ -76,6 +79,6 @@ requirements: []
|
|
76
79
|
rubygems_version: 3.3.7
|
77
80
|
signing_key:
|
78
81
|
specification_version: 4
|
79
|
-
summary:
|
80
|
-
|
82
|
+
summary: Safely use polymorphic associations by validating which classes are allowed
|
83
|
+
to be related to.
|
81
84
|
test_files: []
|