Skip to content

Commit 0e7dcb2

Browse files
authored
Merge pull request #22 from clio/version-0.2.0
Update to version 0.2.0
2 parents 9c7e5a3 + a4faba4 commit 0e7dcb2

File tree

4 files changed

+39
-9
lines changed

4 files changed

+39
-9
lines changed

.github/workflows/ci.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,10 @@ jobs:
1515
fail-fast: false
1616
matrix:
1717
ruby-version:
18-
- 2.7
1918
- 3.0
2019
- 3.1
2120
- 3.2
2221
active-record-version:
23-
- 6.0.0
2422
- 6.1.0
2523
- 7.0.0
2624
- 7.1.0

.github/workflows/gem-push.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Ruby Gem
2+
3+
on:
4+
release:
5+
types: [ published ]
6+
7+
jobs:
8+
build:
9+
name: Build + Publish
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
14+
steps:
15+
- uses: actions/checkout@v3
16+
- name: Set up Ruby 3.1
17+
uses: ruby/setup-ruby@v1
18+
with:
19+
ruby-version: 3.1
20+
21+
- name: Publish to RubyGems
22+
env:
23+
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
24+
run: |
25+
mkdir -p $HOME/.gem
26+
touch $HOME/.gem/credentials
27+
chmod 0600 $HOME/.gem/credentials
28+
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
29+
gem build *.gemspec
30+
gem push *.gem

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@ class CreateCompanies < ActiveRecord::Migration
2222
end
2323
```
2424

25-
The problem with this approach is that `type` is a string (and by default it is 255 characters). This is a little ridiculous. For comparison, if we had a state machine with X states, would we describe the states with strings `"State1", "State2", etc` or would we just enumerate the state column and make it an integer? This gem will allow us to use an integer for the `type` column.
25+
The problem with this approach is that `type` is a string (and by default it is 255 characters). This is a little ridiculous. For comparison, if we had a state machine with X states, would we describe the states with strings `"State1", "State2", etc` or would we just enumerate the state column and make it an integer? This gem will allow us to use an integer for the `type` column.
2626

2727
## Installation
2828

29+
_Current versions of this gem (>= v0.2.0) only support Ruby 3+ and ActiveRecord >= v6.1. For Ruby <= v2.7 or ActiveRecord <= 6.0, use v0.1.3._
30+
2931
Add this line to your application's Gemfile:
3032

3133
gem 'inheritance_integer_type'
@@ -42,28 +44,28 @@ Or install it yourself as:
4244

4345
The gem is pretty straightforward to use.
4446

45-
First, set the `integer_inheritance` value on each of the subclasses.
47+
First, set the `integer_inheritance` value on each of the subclasses.
4648
```ruby
4749
class Firm < Company
4850
self.integer_inheritance = 1
4951
end
50-
52+
5153
class Client < Company
5254
self.integer_inheritance = 2
5355
end
54-
56+
5557
class PriorityClient < Client
5658
self.integer_inheritance = 3
5759
end
5860
```
5961

6062

61-
Note: The mapping here can start from whatever integer you wish, but I would advise not using 0. The reason being that if you had a new class, for instance `PriorityFirm`, but forgot to include set the mapping, it would effectively get `to_i` called on it and stored in the database. `"Priority".to_i == 0`, so if your mapping included 0, this would create a weird bug.
63+
Note: The mapping here can start from whatever integer you wish, but I would advise not using 0. The reason being that if you had a new class, for instance `PriorityFirm`, but forgot to include set the mapping, it would effectively get `to_i` called on it and stored in the database. `"Priority".to_i == 0`, so if your mapping included 0, this would create a weird bug.
6264

6365
If you want to convert a polymorphic association that is already a string, you'll need to set up a migration. (Assuming SQL for the time being, but this should be pretty straightforward.)
6466
```ruby
6567
class CompanyToIntegerType < ActiveRecord::Migration
66-
68+
6769
def up
6870
change_table :companies do |t|
6971
t.integer :new_type
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module InheritanceIntegerType
2-
VERSION = "0.1.3"
2+
VERSION = "0.2.0"
33
end

0 commit comments

Comments
 (0)