classy_enum 3.5.0.beta → 3.5.0.beta2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e52f5ea1617ac0e9a89994cfab27f12faec5d1ce
4
- data.tar.gz: 37e5e8fac14f20a572df511fa7403f031b0b93c7
3
+ metadata.gz: 7c9cde1bdb7247280e799808a39db0570abaf562
4
+ data.tar.gz: 5035c1f14cd57b1cae291d2e72965405ced52a81
5
5
  SHA512:
6
- metadata.gz: e60ebb8312ab9245e951785798023ad5b21583da87382b5f0da025e08757deb7626ef7c5f2248e72f9d44aaf2f90fe0731092ff82e617122bcdd7386f6aa0dfc
7
- data.tar.gz: 79ede4de8ff0e03de2e41fe9f77ad4e5fcc35fea0db19af23ccd92915d692df10d50d1458a98dfea13e9298fd0d38560ecedf776e73dc1962e3da9c5c133bc01
6
+ metadata.gz: 6626df6593a758567591ec992d6d61975dc5e45237750bfba606a41b78dccc3600d764cc8cd6be19a3943c3aca19c4f4be5a65cdb25c30cc279fb5ff5574e83d
7
+ data.tar.gz: 8154db20d27ec5dacb88f278f733b46a310af637e9e5551b6c95d6e4a2380713ceef3345c28c69ba14dde306f59791ca47eae91e000e84334d696100fa2203ff
@@ -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
@@ -1,3 +1,3 @@
1
1
  module ClassyEnum
2
- VERSION = "3.5.0.beta"
2
+ VERSION = "3.5.0.beta2"
3
3
  end
@@ -53,7 +53,7 @@ class AllowNilBreedDog < Dog
53
53
  end
54
54
 
55
55
  class OtherDog < Dog
56
- classy_enum_attr :other_breed, :enum => 'Breed'
56
+ classy_enum_attr :other_breed, :class_name => 'Breed'
57
57
  end
58
58
 
59
59
  describe DefaultDog do
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.beta
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-15 00:00:00.000000000 Z
11
+ date: 2014-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord