serialize_has_many 0.0.1 → 0.0.2
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.
- checksums.yaml +8 -8
- data/README.md +2 -0
- data/lib/serialize_has_many/serializer.rb +8 -2
- data/lib/serialize_has_many/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NzYzYTU1YWE0NGJmM2QyZGQzZDY1MWQ1NDAzMzc0MWQ5NzJhY2FkMQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZjBjMzBkYzJhZWI0ZWRkZTQxZTE2N2VlZGE3YmVjNjY1MWMxMzA4NQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MmU5NWVlODlhNTZkNzVkMDExNWVlMjczYmY2MzY4OTEyNjllMTY2MTc4MzAx
|
10
|
+
YTdjMjI1Y2I4Y2E5ZTI4YjY1ZTNjM2Q3Y2ZlNTE5ZTI3NDJlODEzYmY1NWEw
|
11
|
+
NTMwNjM5NjNhZmJkNWNjOWNjMWMyZWUwZTBiMDhiODgxNTk0MWI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
Mzk3OWI2NTlhN2NhZjM5ODY0MmNiZDM0MTIwNTBlYzE4Y2VlODEzZDJmODVi
|
14
|
+
YWNmYWZkYmJjOGQ5ZWE2MDhhNGRkYmI4MjZhNmRhNTZlOTMxZjdjNGU1M2M1
|
15
|
+
NjY1NzQwNTk4MWYxNzUyOTNhNzk1YWE3Nzk2OTQwOGUzN2U0NDg=
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# SerializeHasMany
|
2
2
|
|
3
|
+
[](https://travis-ci.org/rdsubhas/serialize_has_many)
|
4
|
+
|
3
5
|
Serializes `has_many` relationships into a single column while still doing attributes, validations, callbacks, nested forms and fields_for. Easy NoSQL with ActiveRecord.
|
4
6
|
|
5
7
|
## Installation
|
@@ -41,13 +41,19 @@ module SerializeHasMany
|
|
41
41
|
def from_item(item)
|
42
42
|
case item
|
43
43
|
when nil then nil
|
44
|
+
when Hash then @child_class.new(item)
|
44
45
|
when @child_class then item
|
45
|
-
else
|
46
|
+
else raise('item is of invalid type')
|
46
47
|
end
|
47
48
|
end
|
48
49
|
|
49
50
|
def to_item(item)
|
50
|
-
|
51
|
+
case item
|
52
|
+
when nil then nil
|
53
|
+
when Hash then item
|
54
|
+
when @child_class then item.attributes
|
55
|
+
else raise('item is of invalid type')
|
56
|
+
end
|
51
57
|
end
|
52
58
|
end
|
53
59
|
end
|