active_enum 0.9.4 → 0.9.5

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,6 @@
1
+ [0.9.5] : 2011-09-11
2
+ - Fix regression in enumerate method to not override set of enumerated attributes with each call. [TeWu]
3
+
1
4
  [0.9.4] : 2011-09-08
2
5
  - Replaced usage of deprecated class_inheritable_accessor with class_attribute.
3
6
 
@@ -27,6 +27,7 @@ module ActiveEnum
27
27
  #
28
28
  def enumerate(*attributes, &block)
29
29
  options = attributes.extract_options!
30
+ self.enumerated_attributes ||= {}
30
31
 
31
32
  attributes_enum = {}
32
33
  attributes.each do |attribute|
@@ -46,7 +47,7 @@ module ActiveEnum
46
47
  raise ActiveEnum::EnumNotFound, "Enum class could not be found for attribute '#{attribute}' in class #{self}. Specify the enum class using the :with option."
47
48
  end
48
49
  end
49
- self.enumerated_attributes = attributes_enum
50
+ enumerated_attributes.merge!(attributes_enum)
50
51
  end
51
52
 
52
53
  def active_enum_for(attribute)
@@ -1,3 +1,3 @@
1
1
  module ActiveEnum
2
- VERSION = '0.9.4'
2
+ VERSION = '0.9.5'
3
3
  end
@@ -22,12 +22,22 @@ describe ActiveEnum::Extensions do
22
22
 
23
23
  it 'should allow multiple attributes to be enumerated with same enum' do
24
24
  Person.enumerate :attending, :staying, :with => Accepted
25
+
25
26
  Person.active_enum_for(:attending).should == Accepted
26
27
  Person.active_enum_for(:staying).should == Accepted
27
28
  end
28
29
 
30
+ it 'should allow multiple attributes to be enumerated with different enums' do
31
+ Person.enumerate :sex, :with => Sex
32
+ Person.enumerate :attending, :with => Accepted
33
+
34
+ Person.active_enum_for(:sex).should == Sex
35
+ Person.active_enum_for(:attending).should == Accepted
36
+ end
37
+
29
38
  it 'should allow implicit enumeration class from attribute name' do
30
39
  Person.enumerate :sex
40
+
31
41
  Person.active_enum_for(:sex).should == Sex
32
42
  end
33
43
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_enum
3
3
  version: !ruby/object:Gem::Version
4
- hash: 51
4
+ hash: 49
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
- - 4
10
- version: 0.9.4
9
+ - 5
10
+ version: 0.9.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Adam Meehan
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-09-08 00:00:00 +10:00
18
+ date: 2011-09-11 00:00:00 +10:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency