sti_fallback 0.1.0 → 1.0.0
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 +6 -2
- data/lib/sti_fallback/version.rb +1 -1
- data/sti_fallback.gemspec +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: bc5d7d1e5c0961b6fad4c89f13519bd5260010d1823b34cb6a52a434d652bc5a
|
|
4
|
+
data.tar.gz: 2b6cfc3059f4002f8a074d6999ab4f0e991f3eff68d51aac908765c331b69b01
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ce94398f50210671cb14e8cd1f1b839bf48f3cfe970921f4feb636499da6b42fc30959f112ee7cd616a9baa03177e52a2328e37822dc5abcdb1e1a192e7468a3
|
|
7
|
+
data.tar.gz: f588b6b097591f127e23d9c5079a18da598133f89b18283243884512bef2575687b5292d7052db31b3426e43d138f84ab814a297705e253ec0e582c1051d4fda
|
data/README.md
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
# StiFallback
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Imagine you're using [STI](https://api.rubyonrails.org/classes/ActiveRecord/Inheritance.html) and getting a `type` column from your users. You want to validate that the type is one of the expected values instead of letting ActiveRecord raise an error when the subclass is not found.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
This can be achieved by defining a validation rule on the base mode and falling back to it when the subclass is not found.
|
|
6
|
+
|
|
7
|
+
This gem provides a simple way to do that.
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
6
10
|
|
|
7
11
|
```ruby
|
|
8
12
|
class Action < ApplicationRecord
|
data/lib/sti_fallback/version.rb
CHANGED
data/sti_fallback.gemspec
CHANGED
|
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
|
|
|
31
31
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
|
32
32
|
spec.require_paths = ["lib"]
|
|
33
33
|
|
|
34
|
-
spec.add_dependency "activerecord", "~>
|
|
34
|
+
spec.add_dependency "activerecord", "~> 7.0"
|
|
35
35
|
spec.add_development_dependency "rake", "~> 13.0"
|
|
36
36
|
|
|
37
37
|
# For more information and examples about making a new gem, check out our
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sti_fallback
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ostap Brehin
|
|
@@ -16,14 +16,14 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
19
|
+
version: '7.0'
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '
|
|
26
|
+
version: '7.0'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: rake
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|