classy_enum 3.5.0.beta → 3.5.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +19 -1
- data/README.md +1 -1
- data/lib/classy_enum/active_record.rb +1 -1
- data/lib/classy_enum/version.rb +1 -1
- data/spec/classy_enum/active_record_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c9cde1bdb7247280e799808a39db0570abaf562
|
4
|
+
data.tar.gz: 5035c1f14cd57b1cae291d2e72965405ced52a81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6626df6593a758567591ec992d6d61975dc5e45237750bfba606a41b78dccc3600d764cc8cd6be19a3943c3aca19c4f4be5a65cdb25c30cc279fb5ff5574e83d
|
7
|
+
data.tar.gz: 8154db20d27ec5dacb88f278f733b46a310af637e9e5551b6c95d6e4a2380713ceef3345c28c69ba14dde306f59791ca47eae91e000e84334d696100fa2203ff
|
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,27 @@
|
|
1
1
|
# ClassyEnum Changelog
|
2
2
|
|
3
|
-
## 3.5.0
|
3
|
+
## 3.5.0 (Unreleased)
|
4
4
|
|
5
5
|
* Fixes long standing issue with default values not being persisted to
|
6
6
|
the database. See issue #37.
|
7
|
+
* Updates `classy_enum_attr` method to accept class_name as an argument as
|
8
|
+
an alias for `enum`. This is to bring the API closer to how
|
9
|
+
ActiveRecord overrides class names on associations.
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
class Alarm < ActiveRecord::Base
|
13
|
+
classy_enum_attr :priority, enum: 'AlarmPriority'
|
14
|
+
end
|
15
|
+
```
|
16
|
+
|
17
|
+
is now equivalent to:
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
class Alarm < ActiveRecord::Base
|
21
|
+
classy_enum_attr :priority, class_name: 'AlarmPriority'
|
22
|
+
end
|
23
|
+
```
|
24
|
+
|
7
25
|
|
8
26
|
## 3.4.0
|
9
27
|
|
data/README.md
CHANGED
@@ -134,7 +134,7 @@ The enum field works like any other model attribute. It can be mass-assigned usi
|
|
134
134
|
|
135
135
|
#### What if your enum class name is not the same as your model's attribute name?
|
136
136
|
|
137
|
-
Just provide an optional `enum` argument to declare the attribute name. In this case, the model's attribute is called *alarm_priority*.
|
137
|
+
Just provide an optional `enum` or `class_name` argument to declare the attribute name. In this case, the model's attribute is called *alarm_priority*.
|
138
138
|
|
139
139
|
```ruby
|
140
140
|
class Alarm < ActiveRecord::Base
|
@@ -53,7 +53,7 @@ module ClassyEnum
|
|
53
53
|
# # Specifying a default enum value
|
54
54
|
# classy_enum_attr :priority, :default => 'low'
|
55
55
|
def classy_enum_attr(attribute, options={})
|
56
|
-
enum = (options[:enum] || attribute).to_s.camelize.constantize
|
56
|
+
enum = (options[:enum] || options[:class_name] || attribute).to_s.camelize.constantize
|
57
57
|
allow_blank = options[:allow_blank] || false
|
58
58
|
allow_nil = options[:allow_nil] || false
|
59
59
|
serialize_as_json = options[:serialize_as_json] || false
|
data/lib/classy_enum/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: classy_enum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.5.0.
|
4
|
+
version: 3.5.0.beta2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Brown
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|