mamechiwa 0.0.0 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/mamechiwa/version.rb +1 -1
- data/lib/mamechiwa.rb +12 -5
- metadata +1 -1
data/lib/mamechiwa/version.rb
CHANGED
data/lib/mamechiwa.rb
CHANGED
@@ -28,7 +28,10 @@ module Mamechiwa
|
|
28
28
|
define_method :initialize_with_mame do
|
29
29
|
unless @mame_embedded
|
30
30
|
group = self.class.mame_group_field.size > 0 ? self.send(self.class.mame_group_field).to_s : ""
|
31
|
-
|
31
|
+
|
32
|
+
if self.class.mame_config[group] && self.class.mame_config[group][:class]
|
33
|
+
@mame_embedded = self.class.mame_config[group][:class].new(self, field)
|
34
|
+
end
|
32
35
|
end
|
33
36
|
end
|
34
37
|
|
@@ -42,10 +45,14 @@ module Mamechiwa
|
|
42
45
|
|
43
46
|
define_method :mame_validator do
|
44
47
|
initialize_with_mame
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
48
|
+
|
49
|
+
unless @mame_embedded
|
50
|
+
errors.add("#{field}", "#{self.class.mame_group_field} is unregistered type.")
|
51
|
+
else
|
52
|
+
if !@mame_embedded.valid?
|
53
|
+
@mame_embedded.errors.each do |k, v|
|
54
|
+
errors.add("#{field}[#{k}]", v)
|
55
|
+
end
|
49
56
|
end
|
50
57
|
end
|
51
58
|
end
|