mamechiwa 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  module Mamechiwa
2
2
  module Version
3
- STRING = "0.0.2"
3
+ STRING = "0.0.3"
4
4
  end
5
5
  end
data/lib/mamechiwa.rb CHANGED
@@ -27,13 +27,23 @@ module Mamechiwa
27
27
  class_eval do
28
28
  define_method :initialize_with_mame do
29
29
  unless @mame_embedded
30
- group = self.class.mame_group_field.length > 0 ? self.send(self.class.mame_group_field).to_s : ""
30
+ group = self.class.mame_group_field.length > 0 ? self.send(self.class.mame_group_field).to_s : ""
31
31
 
32
32
  if self.class.mame_config[group] && self.class.mame_config[group][:class]
33
33
  @mame_embedded = self.class.mame_config[group][:class].new(self, field)
34
34
  end
35
35
  end
36
36
  end
37
+
38
+ define_method "#{field}=" do |value|
39
+ if value.is_a?(Hash)
40
+ write_attribute("#{field}", value.to_json)
41
+ else
42
+ write_attribute("#{field}", value)
43
+ end
44
+
45
+ initialize_with_mame
46
+ end
37
47
 
38
48
  define_method "#{field}" do
39
49
  initialize_with_mame
@@ -93,10 +103,10 @@ module Mamechiwa
93
103
  @mame_parent = parent
94
104
  @mame_parent_field = field
95
105
 
96
- value = @mame_parent.send(:[], @mame_parent_field)
106
+ value = @mame_parent.send(:read_attribute, @mame_parent_field)
97
107
 
98
108
  mame_attrs.each do |attr|
99
- self[attr.to_s] = nil
109
+ self.old_set(attr.to_s, nil)
100
110
  end
101
111
 
102
112
  if value
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mamechiwa
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-05-17 00:00:00.000000000 Z
12
+ date: 2012-05-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord