enumerate_it 0.7.14 → 0.7.15

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- enumerate_it (0.7.13)
5
- activesupport (>= 2.3.2)
4
+ enumerate_it (0.7.14)
5
+ activesupport (>= 3.0.0)
6
6
 
7
7
  GEM
8
8
  remote: http://rubygems.org/
data/lib/enumerate_it.rb CHANGED
@@ -201,6 +201,8 @@
201
201
  # - You can add behaviour to the enumeration class.
202
202
  # - You can reuse the enumeration inside other classes.
203
203
  #
204
+
205
+ require "active_support/core_ext/class/attribute"
204
206
  module EnumerateIt
205
207
  class Base
206
208
  @@registered_enumerations = {}
@@ -276,6 +278,8 @@ module EnumerateIt
276
278
 
277
279
  module ClassMethods
278
280
  def has_enumeration_for(attribute, options = {})
281
+ self.enumerations = self.enumerations.dup
282
+
279
283
  define_enumeration_class attribute, options
280
284
  set_validations attribute, options
281
285
  create_enumeration_humanize_method options[:with], attribute
@@ -290,10 +294,6 @@ module EnumerateIt
290
294
  end
291
295
  end
292
296
 
293
- def enumerations
294
- @_enumerations ||= {}
295
- end
296
-
297
297
  private
298
298
 
299
299
  def store_enumeration(klass, attribute)
@@ -355,6 +355,9 @@ module EnumerateIt
355
355
  end
356
356
 
357
357
  def self.included(receiver)
358
+ receiver.class_attribute :enumerations, :instance_writer => false, :instance_reader => false
359
+ receiver.enumerations = {}
360
+
358
361
  receiver.extend ClassMethods
359
362
  end
360
363
  end
@@ -1,3 +1,3 @@
1
1
  module EnumerateIt
2
- VERSION = "0.7.14"
2
+ VERSION = "0.7.15"
3
3
  end
@@ -73,6 +73,20 @@ describe EnumerateIt do
73
73
  TestClass.enumerations[:foobar].should == TestEnumeration
74
74
  end
75
75
 
76
+ context 'use the same enumeration from an inherited class' do
77
+ before do
78
+ class SomeClass < BaseClass
79
+ end
80
+ @target = SomeClass.new
81
+ end
82
+
83
+ it 'should have use the correct class' do
84
+ @base = BaseClass.new
85
+ @base.class.enumerations[:foobar].should == TestEnumeration
86
+ @target.class.enumerations[:foobar].should == TestEnumeration
87
+ end
88
+ end
89
+
76
90
  context 'declaring a simple enum on an inherited class' do
77
91
  before do
78
92
  class SomeClass < BaseClass
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enumerate_it
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.14
4
+ version: 0.7.15
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,22 +9,27 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-02 00:00:00.000000000 Z
12
+ date: 2012-06-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
- requirement: &2159371700 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
- version: 2.3.2
21
+ version: 3.0.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2159371700
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 3.0.0
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: rake
27
- requirement: &2159371020 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: '0'
33
38
  type: :development
34
39
  prerelease: false
35
- version_requirements: *2159371020
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: rspec
38
- requirement: &2159386540 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ! '>='
@@ -43,10 +53,15 @@ dependencies:
43
53
  version: 2.5.0
44
54
  type: :development
45
55
  prerelease: false
46
- version_requirements: *2159386540
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 2.5.0
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: activerecord
49
- requirement: &2159385820 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ! '>='
@@ -54,7 +69,12 @@ dependencies:
54
69
  version: 3.0.5
55
70
  type: :development
56
71
  prerelease: false
57
- version_requirements: *2159385820
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: 3.0.5
58
78
  description: Have a legacy database and need some enumerations in your models to match
59
79
  those stupid '4 rows/2 columns' tables with foreign keys and stop doing joins just
60
80
  to fetch a simple description? Or maybe use some integers instead of strings as
@@ -105,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
125
  version: '0'
106
126
  requirements: []
107
127
  rubyforge_project:
108
- rubygems_version: 1.8.15
128
+ rubygems_version: 1.8.24
109
129
  signing_key:
110
130
  specification_version: 3
111
131
  summary: Ruby Enumerations