simple_enum 1.5.1 → 1.6.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/README.rdoc +22 -8
- data/gemfiles/rails-3.0.gemfile.lock +18 -21
- data/gemfiles/rails-3.1.gemfile.lock +22 -25
- data/gemfiles/rails-3.2.gemfile.lock +21 -24
- data/lib/simple_enum.rb +12 -9
- data/lib/simple_enum/enum_hash.rb +2 -1
- data/lib/simple_enum/mongoid.rb +2 -3
- data/lib/simple_enum/version.rb +1 -1
- data/test/orm/active_record.rb +2 -3
- data/test/simple_enum_test.rb +26 -9
- metadata +32 -34
- data/test/models.rb +0 -18
data/Gemfile.lock
CHANGED
data/README.rdoc
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
= SimpleEnum - unobtrusive enum-like fields for ActiveRecord
|
1
|
+
= SimpleEnum - unobtrusive enum-like fields for ActiveRecord {<img src="https://secure.travis-ci.org/lwe/simple_enum.png" />}[http://travis-ci.org/lwe/simple_enum]
|
2
2
|
|
3
3
|
A Rails plugin which brings easy-to-use enum-like functionality to
|
4
4
|
ActiveRecord and Mongoid models (now compatible with rails 3.1, ruby 1.9 and jruby).
|
@@ -97,6 +97,20 @@ useful when creating queries, displaying option elements or similar:
|
|
97
97
|
as_enum :gender, [:male, :female], :column => 'sex'
|
98
98
|
end
|
99
99
|
|
100
|
+
It's not allowed to use the same column name as the enum name, this has been deprecated since 1.4.x and will be
|
101
|
+
removed in 1.6.x.
|
102
|
+
* Want support for ActiveRecords dirty attributes, provide <tt>:dirty => true</tt> as option, which automatically adds both
|
103
|
+
the <tt>{enum}_changed?</tt> and <tt>{enum}_was</tt> methods, which delegate to ActiveRecord.
|
104
|
+
|
105
|
+
class User < ActiveRecord::Base
|
106
|
+
as_enum :gender, [:male, :female], :dirty => true
|
107
|
+
end
|
108
|
+
|
109
|
+
@user = User.where(:gender_cd => User.male).first
|
110
|
+
@user.gender = :female
|
111
|
+
@user.gender_was
|
112
|
+
# => :male
|
113
|
+
|
100
114
|
* Need to provide custom options for the mongoid field, or skip the automatically generated field?
|
101
115
|
|
102
116
|
# skip field generation
|
@@ -106,10 +120,6 @@ useful when creating queries, displaying option elements or similar:
|
|
106
120
|
# custom field options (directly passed to Mongoid::Document#field)
|
107
121
|
as_enum :gender, [:male, :female], :field => { :type => Integer, :default => 1 }
|
108
122
|
|
109
|
-
* To make it easier to create dropdowns with values use:
|
110
|
-
|
111
|
-
<%= select(:user, :gender, User.genders.keys) %>
|
112
|
-
|
113
123
|
* It's possible to validate the internal enum values, just like any other ActiveRecord validation:
|
114
124
|
|
115
125
|
class User < ActiveRecord::Base
|
@@ -172,6 +182,10 @@ useful when creating queries, displaying option elements or similar:
|
|
172
182
|
as_enum :gender, [:male, :female], :whiny => false
|
173
183
|
end
|
174
184
|
|
185
|
+
* To make it easier to create dropdowns with values use:
|
186
|
+
|
187
|
+
<%= select(:user, :gender, User.genders.keys) %>
|
188
|
+
|
175
189
|
* Need translated keys et al in your forms? SimpleEnum provides a <tt><enum>_for_select</tt> method:
|
176
190
|
|
177
191
|
# on the gender field
|
@@ -199,9 +213,9 @@ useful when creating queries, displaying option elements or similar:
|
|
199
213
|
== Best practices
|
200
214
|
|
201
215
|
Do not use the same name for the enum as for the column, note that this mode of use is
|
202
|
-
deprecated
|
216
|
+
deprecated since version 1.4.1 and raises an ArgumentError starting from version 1.6.0:
|
203
217
|
|
204
|
-
# BAD
|
218
|
+
# BAD: raises ArgumentError
|
205
219
|
as_enum :status, [:active, :inactive, :archived], :column => "status"
|
206
220
|
|
207
221
|
# GOOD
|
@@ -252,7 +266,7 @@ or <em>b)</em> a custom method to convert an object to a symbolized form named +
|
|
252
266
|
== Known issues/Open items
|
253
267
|
|
254
268
|
* Maybe the <tt>:whiny</tt> option should default to <tt>false</tt>, so that generally no exceptions are thrown if a user fakes a request?
|
255
|
-
*
|
269
|
+
* Convert to RSpec and clean up tests
|
256
270
|
* Make `:slim => true` the default option...?
|
257
271
|
|
258
272
|
== Contributors
|
@@ -1,46 +1,43 @@
|
|
1
1
|
PATH
|
2
2
|
remote: /Users/lukas/Projects/_github/simple_enum
|
3
3
|
specs:
|
4
|
-
simple_enum (1.
|
4
|
+
simple_enum (1.6.1)
|
5
5
|
activesupport (>= 3.0.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: http://rubygems.org/
|
9
9
|
specs:
|
10
|
-
activemodel (3.0.
|
11
|
-
activesupport (= 3.0.
|
10
|
+
activemodel (3.0.15)
|
11
|
+
activesupport (= 3.0.15)
|
12
12
|
builder (~> 2.1.2)
|
13
13
|
i18n (~> 0.5.0)
|
14
|
-
activerecord (3.0.
|
15
|
-
activemodel (= 3.0.
|
16
|
-
activesupport (= 3.0.
|
14
|
+
activerecord (3.0.15)
|
15
|
+
activemodel (= 3.0.15)
|
16
|
+
activesupport (= 3.0.15)
|
17
17
|
arel (~> 2.0.10)
|
18
18
|
tzinfo (~> 0.3.23)
|
19
|
-
activesupport (3.0.
|
20
|
-
appraisal (0.4.
|
19
|
+
activesupport (3.0.15)
|
20
|
+
appraisal (0.4.1)
|
21
21
|
bundler
|
22
22
|
rake
|
23
23
|
arel (2.0.10)
|
24
|
-
bson (1.
|
25
|
-
|
26
|
-
|
27
|
-
bson (= 1.5.2)
|
24
|
+
bson (1.6.4)
|
25
|
+
bson_ext (1.6.4)
|
26
|
+
bson (~> 1.6.4)
|
28
27
|
builder (2.1.2)
|
29
28
|
i18n (0.5.0)
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
activemodel (~> 3.0)
|
29
|
+
minitest (3.2.0)
|
30
|
+
mongo (1.6.4)
|
31
|
+
bson (~> 1.6.4)
|
32
|
+
mongoid (2.2.6)
|
33
|
+
activemodel (~> 3.0.0)
|
36
34
|
mongo (~> 1.3)
|
37
35
|
tzinfo (~> 0.3.22)
|
38
36
|
rake (0.9.2.2)
|
39
|
-
sqlite3 (1.3.
|
40
|
-
tzinfo (0.3.
|
37
|
+
sqlite3 (1.3.6)
|
38
|
+
tzinfo (0.3.33)
|
41
39
|
|
42
40
|
PLATFORMS
|
43
|
-
java
|
44
41
|
ruby
|
45
42
|
|
46
43
|
DEPENDENCIES
|
@@ -1,48 +1,45 @@
|
|
1
1
|
PATH
|
2
2
|
remote: /Users/lukas/Projects/_github/simple_enum
|
3
3
|
specs:
|
4
|
-
simple_enum (1.
|
4
|
+
simple_enum (1.6.1)
|
5
5
|
activesupport (>= 3.0.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: http://rubygems.org/
|
9
9
|
specs:
|
10
|
-
activemodel (3.1.
|
11
|
-
activesupport (= 3.1.
|
10
|
+
activemodel (3.1.6)
|
11
|
+
activesupport (= 3.1.6)
|
12
12
|
builder (~> 3.0.0)
|
13
13
|
i18n (~> 0.6)
|
14
|
-
activerecord (3.1.
|
15
|
-
activemodel (= 3.1.
|
16
|
-
activesupport (= 3.1.
|
17
|
-
arel (~> 2.2.
|
14
|
+
activerecord (3.1.6)
|
15
|
+
activemodel (= 3.1.6)
|
16
|
+
activesupport (= 3.1.6)
|
17
|
+
arel (~> 2.2.3)
|
18
18
|
tzinfo (~> 0.3.29)
|
19
|
-
activesupport (3.1.
|
20
|
-
multi_json (
|
21
|
-
appraisal (0.4.
|
19
|
+
activesupport (3.1.6)
|
20
|
+
multi_json (>= 1.0, < 1.3)
|
21
|
+
appraisal (0.4.1)
|
22
22
|
bundler
|
23
23
|
rake
|
24
|
-
arel (2.2.
|
25
|
-
bson (1.
|
26
|
-
|
27
|
-
|
28
|
-
bson (= 1.5.2)
|
24
|
+
arel (2.2.3)
|
25
|
+
bson (1.6.4)
|
26
|
+
bson_ext (1.6.4)
|
27
|
+
bson (~> 1.6.4)
|
29
28
|
builder (3.0.0)
|
30
29
|
i18n (0.6.0)
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
mongoid (2.4.1)
|
30
|
+
minitest (3.2.0)
|
31
|
+
mongo (1.6.2)
|
32
|
+
bson (~> 1.6.2)
|
33
|
+
mongoid (2.4.11)
|
36
34
|
activemodel (~> 3.1)
|
37
|
-
mongo (
|
35
|
+
mongo (<= 1.6.2)
|
38
36
|
tzinfo (~> 0.3.22)
|
39
|
-
multi_json (1.0
|
37
|
+
multi_json (1.2.0)
|
40
38
|
rake (0.9.2.2)
|
41
|
-
sqlite3 (1.3.
|
42
|
-
tzinfo (0.3.
|
39
|
+
sqlite3 (1.3.6)
|
40
|
+
tzinfo (0.3.33)
|
43
41
|
|
44
42
|
PLATFORMS
|
45
|
-
java
|
46
43
|
ruby
|
47
44
|
|
48
45
|
DEPENDENCIES
|
@@ -1,48 +1,45 @@
|
|
1
1
|
PATH
|
2
2
|
remote: /Users/lukas/Projects/_github/simple_enum
|
3
3
|
specs:
|
4
|
-
simple_enum (1.
|
4
|
+
simple_enum (1.6.1)
|
5
5
|
activesupport (>= 3.0.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: http://rubygems.org/
|
9
9
|
specs:
|
10
|
-
activemodel (3.2.
|
11
|
-
activesupport (= 3.2.
|
10
|
+
activemodel (3.2.6)
|
11
|
+
activesupport (= 3.2.6)
|
12
12
|
builder (~> 3.0.0)
|
13
|
-
activerecord (3.2.
|
14
|
-
activemodel (= 3.2.
|
15
|
-
activesupport (= 3.2.
|
16
|
-
arel (~> 3.0.
|
13
|
+
activerecord (3.2.6)
|
14
|
+
activemodel (= 3.2.6)
|
15
|
+
activesupport (= 3.2.6)
|
16
|
+
arel (~> 3.0.2)
|
17
17
|
tzinfo (~> 0.3.29)
|
18
|
-
activesupport (3.2.
|
18
|
+
activesupport (3.2.6)
|
19
19
|
i18n (~> 0.6)
|
20
20
|
multi_json (~> 1.0)
|
21
|
-
appraisal (0.4.
|
21
|
+
appraisal (0.4.1)
|
22
22
|
bundler
|
23
23
|
rake
|
24
|
-
arel (3.0.
|
25
|
-
bson (1.
|
26
|
-
|
27
|
-
|
28
|
-
bson (= 1.5.2)
|
24
|
+
arel (3.0.2)
|
25
|
+
bson (1.6.4)
|
26
|
+
bson_ext (1.6.4)
|
27
|
+
bson (~> 1.6.4)
|
29
28
|
builder (3.0.0)
|
30
29
|
i18n (0.6.0)
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
mongoid (2.4.1)
|
30
|
+
minitest (3.2.0)
|
31
|
+
mongo (1.6.2)
|
32
|
+
bson (~> 1.6.2)
|
33
|
+
mongoid (2.4.11)
|
36
34
|
activemodel (~> 3.1)
|
37
|
-
mongo (
|
35
|
+
mongo (<= 1.6.2)
|
38
36
|
tzinfo (~> 0.3.22)
|
39
|
-
multi_json (1.
|
37
|
+
multi_json (1.3.6)
|
40
38
|
rake (0.9.2.2)
|
41
|
-
sqlite3 (1.3.
|
42
|
-
tzinfo (0.3.
|
39
|
+
sqlite3 (1.3.6)
|
40
|
+
tzinfo (0.3.33)
|
43
41
|
|
44
42
|
PLATFORMS
|
45
|
-
java
|
46
43
|
ruby
|
47
44
|
|
48
45
|
DEPENDENCIES
|
data/lib/simple_enum.rb
CHANGED
@@ -45,8 +45,7 @@ module SimpleEnum
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def included(base) #:nodoc:
|
48
|
-
base.send :class_attribute, :
|
49
|
-
base.enum_definitions = {}
|
48
|
+
base.send :class_attribute, :simple_enum_definitions, :instance_writer => false, :instance_reader => false
|
50
49
|
base.send :extend, ClassMethods
|
51
50
|
end
|
52
51
|
end
|
@@ -166,11 +165,10 @@ module SimpleEnum
|
|
166
165
|
values_inverted = values.invert
|
167
166
|
|
168
167
|
# store info away
|
169
|
-
self.enum_definitions = {} if self.enum_definitions.nil?
|
170
168
|
self.enum_definitions[enum_cd] = self.enum_definitions[options[:column]] = { :name => enum_cd, :column => options[:column], :options => options }
|
171
169
|
|
172
|
-
#
|
173
|
-
|
170
|
+
# raise error if enum_cd == column
|
171
|
+
raise ArgumentError, "[simple_enum] use different names for #{enum_cd}'s name and column name." if enum_cd.to_s == options[:column].to_s
|
174
172
|
|
175
173
|
# generate getter
|
176
174
|
define_method("#{enum_cd}") do
|
@@ -180,9 +178,10 @@ module SimpleEnum
|
|
180
178
|
|
181
179
|
# generate setter
|
182
180
|
define_method("#{enum_cd}=") do |new_value|
|
183
|
-
|
184
|
-
|
185
|
-
|
181
|
+
real = new_value.blank? ? nil : values[EnumHash.symbolize(new_value)]
|
182
|
+
real = new_value if real.nil? && values_inverted[new_value].present?
|
183
|
+
raise(ArgumentError, "Invalid enumeration value: #{new_value}") if (options[:whiny] and real.nil? and !new_value.blank?)
|
184
|
+
respond_to?(:write_attribute) ? write_attribute(options[:column], real) : send("#{options[:column]}=", real)
|
186
185
|
end
|
187
186
|
|
188
187
|
# generate checker
|
@@ -213,7 +212,7 @@ module SimpleEnum
|
|
213
212
|
end
|
214
213
|
|
215
214
|
class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
|
216
|
-
class_attribute #{enum_attr.inspect}, :
|
215
|
+
class_attribute #{enum_attr.inspect}, :instance_writer => false, :instance_reader => false
|
217
216
|
|
218
217
|
def self.#{attr_name}(*args)
|
219
218
|
return #{enum_attr} if args.first.nil?
|
@@ -272,6 +271,10 @@ module SimpleEnum
|
|
272
271
|
options.reverse_merge! :count => 1, :default => defaults
|
273
272
|
I18n.translate(defaults.shift, options)
|
274
273
|
end
|
274
|
+
|
275
|
+
def enum_definitions
|
276
|
+
self.simple_enum_definitions ||= {}
|
277
|
+
end
|
275
278
|
end
|
276
279
|
end
|
277
280
|
|
@@ -12,7 +12,8 @@ module SimpleEnum
|
|
12
12
|
return sym.to_enum_sym if sym.respond_to?(:to_enum_sym)
|
13
13
|
return sym.to_sym if sym.respond_to?(:to_sym)
|
14
14
|
return sym.name.to_s.parameterize('_').to_sym if sym.respond_to?(:name)
|
15
|
-
sym.to_param.to_sym
|
15
|
+
sym.to_param.to_sym if sym.present? && sym.respond_to?(:to_param)
|
16
|
+
sym unless sym.blank?
|
16
17
|
end
|
17
18
|
|
18
19
|
def initialize(args = [])
|
data/lib/simple_enum/mongoid.rb
CHANGED
@@ -27,8 +27,7 @@ module SimpleEnum
|
|
27
27
|
|
28
28
|
included do
|
29
29
|
# create class level methods
|
30
|
-
class_attribute :
|
31
|
-
enum_definitions = {}
|
30
|
+
class_attribute :simple_enum_definitions, :instance_writer => false, :instance_reader => false
|
32
31
|
end
|
33
32
|
|
34
33
|
module ClassMethods
|
@@ -49,4 +48,4 @@ module SimpleEnum
|
|
49
48
|
alias_method_chain :as_enum, :mongoid
|
50
49
|
end
|
51
50
|
end
|
52
|
-
end
|
51
|
+
end
|
data/lib/simple_enum/version.rb
CHANGED
data/test/orm/active_record.rb
CHANGED
@@ -67,13 +67,12 @@ end
|
|
67
67
|
def named_dummy(class_name, &block)
|
68
68
|
begin
|
69
69
|
return class_name.constantize
|
70
|
-
rescue NameError
|
70
|
+
rescue NameError
|
71
71
|
klass = Object.const_set(class_name, Class.new(ActiveRecord::Base))
|
72
72
|
klass.module_eval do
|
73
73
|
ar32? ? self.table_name = 'dummies' : set_table_name('dummies')
|
74
74
|
instance_eval &block
|
75
75
|
end
|
76
|
-
|
77
76
|
klass
|
78
77
|
end
|
79
78
|
end
|
@@ -81,7 +80,7 @@ end
|
|
81
80
|
class Dummy < ActiveRecord::Base
|
82
81
|
as_enum :gender, [:male, :female]
|
83
82
|
as_enum :word, { :alpha => 'alpha', :beta => 'beta', :gamma => 'gamma'}
|
84
|
-
as_enum :didum, [ :foo, :bar, :foobar ], :column => 'other'
|
83
|
+
as_enum :didum, [ :foo, :bar, :foobar ], :column => 'other'
|
85
84
|
end
|
86
85
|
|
87
86
|
class Gender < ActiveRecord::Base
|
data/test/simple_enum_test.rb
CHANGED
@@ -9,6 +9,15 @@ class SimpleEnumTest < MiniTest::Unit::TestCase
|
|
9
9
|
assert_equal "gender_cd", Dummy.enum_definitions[:gender][:column]
|
10
10
|
end
|
11
11
|
|
12
|
+
def test_enum_definitions_only_available_from_class
|
13
|
+
assert_raises(NoMethodError) { Dummy.new.enum_definitions }
|
14
|
+
assert_raises(NoMethodError) { Dummy.new.enum_definitions= {} }
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_enum_definitions_local_to_model
|
18
|
+
assert_equal nil, Computer.enum_definitions[:gender]
|
19
|
+
end
|
20
|
+
|
12
21
|
def test_getting_the_correct_integer_values_when_setting_to_symbol
|
13
22
|
d = Dummy.new
|
14
23
|
d.gender = :male
|
@@ -28,6 +37,19 @@ class SimpleEnumTest < MiniTest::Unit::TestCase
|
|
28
37
|
assert_equal(false, d.female?)
|
29
38
|
end
|
30
39
|
|
40
|
+
def test_setting_value_as_key
|
41
|
+
d = Dummy.new
|
42
|
+
d.gender = 1
|
43
|
+
assert_equal(:female, d.gender)
|
44
|
+
assert_equal(1, d.gender_cd)
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_setting_value_as_key_in_constructor
|
48
|
+
d = Dummy.new :gender => 1
|
49
|
+
assert_equal(:female, d.gender)
|
50
|
+
assert_equal(1, d.gender_cd)
|
51
|
+
end
|
52
|
+
|
31
53
|
def test_enum_comparisons
|
32
54
|
d = Dummy.new
|
33
55
|
assert_equal(false, d.gender?)
|
@@ -217,19 +239,14 @@ class SimpleEnumTest < MiniTest::Unit::TestCase
|
|
217
239
|
assert_nil(d.gender)
|
218
240
|
end
|
219
241
|
|
220
|
-
def
|
221
|
-
original_behavior = ActiveSupport::Deprecation.behavior
|
242
|
+
def test_argument_error_is_raised_when_using_enum_name_eq_column_name
|
222
243
|
begin
|
223
|
-
expected = 0
|
224
|
-
ActiveSupport::Deprecation.silenced = false
|
225
|
-
ActiveSupport::Deprecation.behavior = Proc.new { |msg, cb| expected += 1 if msg =~ /\[simple_enum\].+gender_cd/ }
|
226
244
|
invalid_dummy = anonymous_dummy do
|
227
245
|
as_enum :gender_cd, [:male, :female], :column => "gender_cd"
|
228
246
|
end
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
ActiveSupport::Deprecation.behavior = original_behavior
|
247
|
+
assert false, "no error raised"
|
248
|
+
rescue ArgumentError => e
|
249
|
+
assert e.to_s =~ /use different names for/, "invalid ArgumentError raised"
|
233
250
|
end
|
234
251
|
end
|
235
252
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_enum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 13
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
8
|
+
- 6
|
9
9
|
- 1
|
10
|
-
version: 1.
|
10
|
+
version: 1.6.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Lukas Westermann
|
@@ -15,11 +15,11 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-06-30 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
|
-
|
22
|
-
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
23
23
|
none: false
|
24
24
|
requirements:
|
25
25
|
- - ">="
|
@@ -30,12 +30,12 @@ dependencies:
|
|
30
30
|
- 0
|
31
31
|
- 0
|
32
32
|
version: 3.0.0
|
33
|
+
requirement: *id001
|
34
|
+
type: :runtime
|
33
35
|
name: activesupport
|
34
|
-
version_requirements: *id001
|
35
|
-
prerelease: false
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
|
-
|
38
|
-
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ">="
|
@@ -46,12 +46,12 @@ dependencies:
|
|
46
46
|
- 9
|
47
47
|
- 2
|
48
48
|
version: 0.9.2
|
49
|
+
requirement: *id002
|
50
|
+
type: :development
|
49
51
|
name: rake
|
50
|
-
version_requirements: *id002
|
51
|
-
prerelease: false
|
52
52
|
- !ruby/object:Gem::Dependency
|
53
|
-
|
54
|
-
|
53
|
+
prerelease: false
|
54
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
55
55
|
none: false
|
56
56
|
requirements:
|
57
57
|
- - ">="
|
@@ -61,12 +61,12 @@ dependencies:
|
|
61
61
|
- 0
|
62
62
|
- 4
|
63
63
|
version: "0.4"
|
64
|
+
requirement: *id003
|
65
|
+
type: :development
|
64
66
|
name: appraisal
|
65
|
-
version_requirements: *id003
|
66
|
-
prerelease: false
|
67
67
|
- !ruby/object:Gem::Dependency
|
68
|
-
|
69
|
-
|
68
|
+
prerelease: false
|
69
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
70
70
|
none: false
|
71
71
|
requirements:
|
72
72
|
- - ">="
|
@@ -77,12 +77,12 @@ dependencies:
|
|
77
77
|
- 3
|
78
78
|
- 0
|
79
79
|
version: 2.3.0
|
80
|
+
requirement: *id004
|
81
|
+
type: :development
|
80
82
|
name: minitest
|
81
|
-
version_requirements: *id004
|
82
|
-
prerelease: false
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
|
85
|
-
|
84
|
+
prerelease: false
|
85
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
86
86
|
none: false
|
87
87
|
requirements:
|
88
88
|
- - ">="
|
@@ -93,12 +93,12 @@ dependencies:
|
|
93
93
|
- 0
|
94
94
|
- 0
|
95
95
|
version: 3.0.0
|
96
|
+
requirement: *id005
|
97
|
+
type: :development
|
96
98
|
name: activerecord
|
97
|
-
version_requirements: *id005
|
98
|
-
prerelease: false
|
99
99
|
- !ruby/object:Gem::Dependency
|
100
|
-
|
101
|
-
|
100
|
+
prerelease: false
|
101
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
102
102
|
none: false
|
103
103
|
requirements:
|
104
104
|
- - ~>
|
@@ -108,12 +108,12 @@ dependencies:
|
|
108
108
|
- 2
|
109
109
|
- 0
|
110
110
|
version: "2.0"
|
111
|
+
requirement: *id006
|
112
|
+
type: :development
|
111
113
|
name: mongoid
|
112
|
-
version_requirements: *id006
|
113
|
-
prerelease: false
|
114
114
|
- !ruby/object:Gem::Dependency
|
115
|
-
|
116
|
-
|
115
|
+
prerelease: false
|
116
|
+
version_requirements: &id007 !ruby/object:Gem::Requirement
|
117
117
|
none: false
|
118
118
|
requirements:
|
119
119
|
- - ">="
|
@@ -122,9 +122,9 @@ dependencies:
|
|
122
122
|
segments:
|
123
123
|
- 0
|
124
124
|
version: "0"
|
125
|
+
requirement: *id007
|
126
|
+
type: :development
|
125
127
|
name: sqlite3
|
126
|
-
version_requirements: *id007
|
127
|
-
prerelease: false
|
128
128
|
description: Provides enum-like fields for ActiveRecord, ActiveModel and Mongoid models.
|
129
129
|
email:
|
130
130
|
- lukas.westermann@gmail.com
|
@@ -162,7 +162,6 @@ files:
|
|
162
162
|
- test/enum_hash_test.rb
|
163
163
|
- test/finders_test.rb
|
164
164
|
- test/locales.yml
|
165
|
-
- test/models.rb
|
166
165
|
- test/mongoid_test.rb
|
167
166
|
- test/object_backed_test.rb
|
168
167
|
- test/orm/active_record.rb
|
@@ -217,7 +216,6 @@ test_files:
|
|
217
216
|
- test/enum_hash_test.rb
|
218
217
|
- test/finders_test.rb
|
219
218
|
- test/locales.yml
|
220
|
-
- test/models.rb
|
221
219
|
- test/mongoid_test.rb
|
222
220
|
- test/object_backed_test.rb
|
223
221
|
- test/orm/active_record.rb
|
data/test/models.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
class Dummy < ActiveRecord::Base
|
2
|
-
as_enum :gender, [:male, :female]
|
3
|
-
as_enum :word, { :alpha => 'alpha', :beta => 'beta', :gamma => 'gamma'}
|
4
|
-
as_enum :didum, [ :foo, :bar, :foobar ], :column => 'other'
|
5
|
-
end
|
6
|
-
|
7
|
-
class Gender < ActiveRecord::Base
|
8
|
-
end
|
9
|
-
|
10
|
-
class Computer < ActiveRecord::Base
|
11
|
-
as_enum :manufacturer, [:dell, :compaq, :apple]
|
12
|
-
as_enum :operating_system, [:windows, :osx, :linux, :bsd]
|
13
|
-
end
|
14
|
-
|
15
|
-
# Used to test STI stuff
|
16
|
-
class SpecificDummy < Dummy
|
17
|
-
set_table_name 'dummies'
|
18
|
-
end
|