activerecord_composed_of_enum 0.0.2 → 0.0.3

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.
@@ -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(:"#{part}=", options[:default]) unless send(part).present?
41
+ send(setter_method_name, options[:default]) unless send(part).present?
40
42
  end
41
43
  end
42
44
 
43
- composed_of(
44
- part,
45
- :class_name => base.name,
46
- :mapping => [enum_column.to_s],
47
- :constructor => lambda { |cd| cd.present? ? enumeration[cd] : nil }
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
@@ -1,7 +1,7 @@
1
1
  module ActiveRecord
2
2
  module ComposedOfEnum
3
3
  unless defined? ActiveRecord::ComposedOfEnum::VERSION
4
- VERSION = '0.0.2'
4
+ VERSION = '0.0.3'
5
5
  end
6
6
  end
7
7
  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.2
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-06-14 00:00:00.000000000 Z
12
+ date: 2012-07-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec