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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MzAzZTE0ODM2OTIxNmY4ZWM2ZjUxYWZhNDQ5Nzk4NDVmZTEyNjhmNw==
4
+ NzYzYTU1YWE0NGJmM2QyZGQzZDY1MWQ1NDAzMzc0MWQ5NzJhY2FkMQ==
5
5
  data.tar.gz: !binary |-
6
- MjlhZDVhY2JmY2I0NmViNmU4NDEzYTFiMmVhNDNkMzc5NzVmNjFhZA==
6
+ ZjBjMzBkYzJhZWI0ZWRkZTQxZTE2N2VlZGE3YmVjNjY1MWMxMzA4NQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YTcxMDhjMzljYmJmNTI3ZDljMWE3MTM5ZDNmMDVmYjViZWNmNzBmNTVlZDNi
10
- MmZiOTA1OGEwZWYyM2QzYTNiZDc1ZWQyMzRjYTA5MzgyMDEwYWY5NDMyNjVi
11
- MWFhNTNmNjA0ZDI5MzE1YTU0Y2M2M2Q2MzFmNmFhNDE2MGMxYjY=
9
+ MmU5NWVlODlhNTZkNzVkMDExNWVlMjczYmY2MzY4OTEyNjllMTY2MTc4MzAx
10
+ YTdjMjI1Y2I4Y2E5ZTI4YjY1ZTNjM2Q3Y2ZlNTE5ZTI3NDJlODEzYmY1NWEw
11
+ NTMwNjM5NjNhZmJkNWNjOWNjMWMyZWUwZTBiMDhiODgxNTk0MWI=
12
12
  data.tar.gz: !binary |-
13
- OWEyNzE4MzdkYWU3OTk5ZWY5YTdmZTNlMTQwNzAwOWFkMTRlNTUwODQzZmJk
14
- NjE1NmViYmJiYzgwYjg0ZjRmNzhlMTlhZTU5NTNkOTU1ZGY4NGFmYmI5YTAx
15
- OTU1ZGI0YTBjOTNlZDA5ZDQ5MTdhODlkMTM2NDY5M2MyYzU4MmM=
13
+ Mzk3OWI2NTlhN2NhZjM5ODY0MmNiZDM0MTIwNTBlYzE4Y2VlODEzZDJmODVi
14
+ YWNmYWZkYmJjOGQ5ZWE2MDhhNGRkYmI4MjZhNmRhNTZlOTMxZjdjNGU1M2M1
15
+ NjY1NzQwNTk4MWYxNzUyOTNhNzk1YWE3Nzk2OTQwOGUzN2U0NDg=
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # SerializeHasMany
2
2
 
3
+ [![Build Status](https://travis-ci.org/rdsubhas/serialize_has_many.svg?branch=master)](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 @child_class.new(item)
46
+ else raise('item is of invalid type')
46
47
  end
47
48
  end
48
49
 
49
50
  def to_item(item)
50
- item ? item.attributes : nil
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
@@ -1,3 +1,3 @@
1
1
  module SerializeHasMany
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: serialize_has_many
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Subhas