activerecord_enum 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.markdown +15 -2
- data/activerecord_enum.gemspec +1 -0
- data/lib/activerecord_enum.rb +11 -0
- data/lib/activerecord_enum/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: afe73598d2530bd5ea7eac013a06440d8cd0f8ef
|
4
|
+
data.tar.gz: caf10fb57232f15dbdaecef3556cc8d50122a269
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8fe42c6d86a2ab53dc9c8ff38a883426599ad4a44989a829dbc04dcbd9989de04f60d391e5eab77bd8957f98bc67186ce6be0374a57faa2e7976e2021d05bb0d
|
7
|
+
data.tar.gz: 5fc0832430001c80986e0f90ab887cc40426004ec858c323aad5375c2d9b849fd2306a3bc0e9e2a10244ff189ea7e255698069b5aeb51ef212b596526414a829
|
data/README.markdown
CHANGED
@@ -26,7 +26,14 @@ Your schema<->db coupling will work again, and it will fall back to a `VARCHAR`
|
|
26
26
|
gem 'activerecord_enum'
|
27
27
|
```
|
28
28
|
|
29
|
-
|
29
|
+
Make sure to put this line *after* the line for your database adapter gem, like so:
|
30
|
+
|
31
|
+
```
|
32
|
+
gem 'mysql2', '~> 0.3.20'
|
33
|
+
gem 'activerecord_enum'
|
34
|
+
```
|
35
|
+
|
36
|
+
That's it!
|
30
37
|
|
31
38
|
## Hypothetically asked questions ##
|
32
39
|
|
@@ -40,6 +47,12 @@ It currently works with:
|
|
40
47
|
|
41
48
|
If you'd like to support other adapters, pull requests are welcome!
|
42
49
|
|
50
|
+
### I thought Rails 4.1+ did enums? ###
|
51
|
+
|
52
|
+
This gem provides compatibility for *native* `ENUM` types in the DB.
|
53
|
+
[ActiveRecord::Enum](http://api.rubyonrails.org/classes/ActiveRecord/Enum.html) is actually a layer that takes an integer column in the DB and *presents* it as an enum type.
|
54
|
+
These are fundamentally different approaches, with different motivations, costs and benefits.
|
55
|
+
|
43
56
|
### Why doesn't it validate anything? ###
|
44
57
|
|
45
58
|
Following ActiveRecord's lead, this plugin doesn't do any validation work itself.
|
@@ -48,7 +61,7 @@ For ENUM columns, you may be satisfied with something simple:
|
|
48
61
|
|
49
62
|
validates_inclusion_of :attr, :in => [ :possible, :values ]
|
50
63
|
|
51
|
-
Or if you prefer more bells and whistles, try [
|
64
|
+
Or if you prefer more bells and whistles, try [brainspec/enumerize](https://github.com/brainspec/enumerize).
|
52
65
|
|
53
66
|
For SET columns, you may be interested in [iangreenleaf/active_set](https://github.com/iangreenleaf/active_set).
|
54
67
|
|
data/activerecord_enum.gemspec
CHANGED
@@ -11,6 +11,7 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.homepage = ""
|
12
12
|
s.summary = %q{Enum data types for ActiveRecord}
|
13
13
|
s.description = %q{Adds the ENUM data type natively to ActiveRecord.}
|
14
|
+
s.post_install_message = %q{The 'activerecord_enum' gem has a new name! Please install the 'native_enum' gem instead.}
|
14
15
|
|
15
16
|
s.rubyforge_project = "activerecord_enum"
|
16
17
|
|
data/lib/activerecord_enum.rb
CHANGED
@@ -14,12 +14,23 @@ end
|
|
14
14
|
module ActiveRecord
|
15
15
|
module ConnectionAdapters
|
16
16
|
class TableDefinition
|
17
|
+
|
17
18
|
def enum *args
|
19
|
+
if defined?(ActiveSupport)
|
20
|
+
ActiveSupport::Deprecation.warn(
|
21
|
+
%q{The 'activerecord_enum' gem has a new name! Please install the 'native_enum' gem instead.}
|
22
|
+
)
|
23
|
+
end
|
18
24
|
options = args.extract_options!
|
19
25
|
column_names = args
|
20
26
|
column_names.each { |name| column(name, :enum, options) }
|
21
27
|
end
|
22
28
|
def set *args
|
29
|
+
if defined?(ActiveSupport)
|
30
|
+
ActiveSupport::Deprecation.warn(
|
31
|
+
%q{The 'activerecord_enum' gem has a new name! Please install the 'native_enum' gem instead.}
|
32
|
+
)
|
33
|
+
end
|
23
34
|
options = args.extract_options!
|
24
35
|
options[:default] = options[:default].join "," if options[:default].present?
|
25
36
|
column_names = args
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord_enum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ian Young
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -133,7 +133,8 @@ files:
|
|
133
133
|
homepage: ''
|
134
134
|
licenses: []
|
135
135
|
metadata: {}
|
136
|
-
post_install_message:
|
136
|
+
post_install_message: The 'activerecord_enum' gem has a new name! Please install the
|
137
|
+
'native_enum' gem instead.
|
137
138
|
rdoc_options: []
|
138
139
|
require_paths:
|
139
140
|
- lib
|