belongs_to_polymorphic 0.1.2 → 0.1.3
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/README.md +19 -0
- data/lib/belongs_to_polymorphic/associations.rb +2 -1
- data/lib/belongs_to_polymorphic/version.rb +1 -1
- data/lib/belongs_to_polymorphic.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d1c2af190a259601a400ab83fc7878d3ba1e9ba155d08920b687d41b551f2af
|
4
|
+
data.tar.gz: e00c21112f674af04124f846d56b9d5c611f29038490aa021ceba0bef87abdd6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a3212e59e3449e9f2da0038cb45bb73b6d9ff212624145ee73a3b98f7f40933c774803008ee8581d6074fdef6aa5bef6d2985c30b3e1e0796daf8999d794ab0
|
7
|
+
data.tar.gz: bb848815e83b195207af66184440442f70416eaf09d90cf054c3a54ea96266d3812873f8ec81dae3567c82df5bf9164fbadb84ceb1cf995aaf43ef7c74c2a3c2
|
data/README.md
CHANGED
@@ -74,6 +74,25 @@ en:
|
|
74
74
|
class_not_allowed: "%{class} is not an allowed class"
|
75
75
|
```
|
76
76
|
|
77
|
+
## Development
|
78
|
+
|
79
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
80
|
+
|
81
|
+
## Contributing
|
82
|
+
|
83
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/gogrow-dev/belongs_to_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/belongs_to_polymorphic/blob/main/CODE_OF_CONDUCT.md).
|
84
|
+
|
77
85
|
## License
|
78
86
|
|
79
87
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
88
|
+
|
89
|
+
## Code of Conduct
|
90
|
+
|
91
|
+
Everyone interacting in the belongs_to_polymorphic project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/gogrow-dev/belongs_to_polymorphic/blob/main/CODE_OF_CONDUCT.md).
|
92
|
+
|
93
|
+
## Credits
|
94
|
+
|
95
|
+
belongs_to_polymorphic is maintained by [GoGrow](https://gogrow.dev) with the help of our
|
96
|
+
[contributors](https://github.com/gogrow-dev/belongs_to_polymorphic/contributors).
|
97
|
+
|
98
|
+
[<img src="https://user-images.githubusercontent.com/9309458/180014465-00477428-fd76-48f6-b984-5b401b8ce241.svg" height="50"/>](https://gogrow.dev)
|
@@ -8,8 +8,9 @@ module BelongsToPolymorphic
|
|
8
8
|
|
9
9
|
module ClassMethods
|
10
10
|
def belongs_to_polymorphic(name, allowed_classes:, **options)
|
11
|
-
allowed_classes = Array.
|
11
|
+
allowed_classes = Array.wrap(allowed_classes)
|
12
12
|
belongs_to name, polymorphic: true, **options
|
13
|
+
|
13
14
|
validates "#{name}_type", inclusion: {
|
14
15
|
in: classes(allowed_classes, options),
|
15
16
|
message: I18n.t('belongs_to_polymorphic.errors.messages.class_not_allowed',
|
@@ -4,7 +4,7 @@ require 'active_record'
|
|
4
4
|
require 'belongs_to_polymorphic/version'
|
5
5
|
require 'belongs_to_polymorphic/associations'
|
6
6
|
|
7
|
-
I18n.load_path <<
|
7
|
+
I18n.load_path << File.expand_path('config/locales/en.yml')
|
8
8
|
|
9
9
|
module BelongsToPolymorphic; end
|
10
10
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: belongs_to_polymorphic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicolas Erlichman
|
@@ -113,11 +113,11 @@ files:
|
|
113
113
|
- lib/belongs_to_polymorphic.rb
|
114
114
|
- lib/belongs_to_polymorphic/associations.rb
|
115
115
|
- lib/belongs_to_polymorphic/version.rb
|
116
|
-
homepage: https://
|
116
|
+
homepage: https://gogrow.dev
|
117
117
|
licenses:
|
118
118
|
- MIT
|
119
119
|
metadata:
|
120
|
-
source_code_uri: https://
|
120
|
+
source_code_uri: https://gogrow.dev
|
121
121
|
rubygems_mfa_required: 'true'
|
122
122
|
post_install_message:
|
123
123
|
rdoc_options: []
|