freyja 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/freyja/base.rb +17 -9
- data/lib/freyja/version.rb +1 -1
- metadata +1 -1
data/lib/freyja/base.rb
CHANGED
@@ -68,11 +68,15 @@ class Freyja::Base
|
|
68
68
|
else
|
69
69
|
value = source[attr]
|
70
70
|
end
|
71
|
-
if
|
72
|
-
|
73
|
-
|
71
|
+
if value.present?
|
72
|
+
if association[:class]
|
73
|
+
translator = association[:class].new(value)
|
74
|
+
result[attr] = translator.as_json
|
75
|
+
else
|
76
|
+
result[attr] = value
|
77
|
+
end
|
74
78
|
else
|
75
|
-
|
79
|
+
# TODO
|
76
80
|
end
|
77
81
|
end
|
78
82
|
end
|
@@ -87,13 +91,17 @@ class Freyja::Base
|
|
87
91
|
else
|
88
92
|
value = source[attr]
|
89
93
|
end
|
90
|
-
if
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
+
if value.present?
|
95
|
+
if association[:class]
|
96
|
+
result[attr] = value.map do |v|
|
97
|
+
translator = association[:class].new(v)
|
98
|
+
translator.as_json
|
99
|
+
end
|
100
|
+
else
|
101
|
+
result[attr] = value
|
94
102
|
end
|
95
103
|
else
|
96
|
-
|
104
|
+
# TODO
|
97
105
|
end
|
98
106
|
end
|
99
107
|
end
|
data/lib/freyja/version.rb
CHANGED