activerecord_composed_of_enum 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
@@ -34,18 +34,20 @@ module ActiveRecord
|
|
34
34
|
:inclusion => 0...enumeration.size
|
35
35
|
)
|
36
36
|
|
37
|
+
setter_method_name = :"#{part}="
|
38
|
+
|
37
39
|
if options.has_key?(:default)
|
38
40
|
after_initialize do
|
39
|
-
send(
|
41
|
+
send(setter_method_name, options[:default]) unless send(part).present?
|
40
42
|
end
|
41
43
|
end
|
42
44
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
45
|
+
define_method(setter_method_name) { |enum| self[enum_column] = enum.send(enum_column) }
|
46
|
+
|
47
|
+
define_method(part) do
|
48
|
+
enum_cd = self[enum_column]
|
49
|
+
enum_cd.present? ? enumeration[enum_cd] : nil
|
50
|
+
end
|
49
51
|
end
|
50
52
|
end
|
51
53
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord_composed_of_enum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-07-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|