simple_params 1.0.2 → 1.0.3

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
- ZmI5M2JjM2JhNGYxNjMwZmM4MGZmODdiZjM3ZDU4MGNmYWVjZWQxMA==
4
+ OGYzOTBkMWI1YTA1MmNlZThiMzZiMzE1MGQyN2NlMmM3NTc1NTMwNQ==
5
5
  data.tar.gz: !binary |-
6
- OTA3NDYyNWZhMmUxODA5ZTc4ZjRkZGJiMjQ3MzQzZDdiZDI2YTY0NQ==
6
+ NjExZWE4N2FiMDZhODJiNjM3M2EyNWFmM2E5Yzk4Y2RhNWM4YTk5ZQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YTc5NWUzOTk0MmNiZTc2ZTY1MTk5OTgwYzg5YWI4ZWU3MTM1ODAzMzM1OWVm
10
- OTA1MGM4OGJhYzYwNmNjNDJiZGRhMWEyYTM5YTRjNGI0OTJlOTRiMDJiMGU5
11
- OGE2YTY0MzM2ODY4NmU0MzQ5Nzc4ZTVjYjcxM2JkNmE2ZjVlYmU=
9
+ MjlmNDFhNzZiMTZlNTI1MDIyZTA3NzZiOGIxNTdjYTg2MTczNTY1OWIzZDY4
10
+ N2VkMTM5NmU3ZDVmNWNkNzE5ZTRmOWNiMzI2OTM0MmNhYTc1NGFkMDlkMTQ1
11
+ N2YyOTc3MmRkMjkyNmYwMDQyY2Q4YTJlNDY0MmMzMThhNzBhM2Y=
12
12
  data.tar.gz: !binary |-
13
- ZDMyYzYxZjU5MmViYTdhNWE3MDczYzAzMmIyODY1NGY1MGQxZDhhMmMzY2Q5
14
- M2E1MmQ1MmMzZTFhMDRjNjQxZWM3ZDRjZjljZGQ2YmYzYzc2YTIzNDAyODdk
15
- OGQyNWExMjAzMTEzOTAyNzQ2ZGFiMjRkOGYxYzFiNTVjYjljM2Q=
13
+ ZmQ2YTBiOWMyYTA4MWYwZmMzNDg2NGJmNTRjNjQwZGVlY2RjY2YwYmYyZGQ1
14
+ MzIzOGRjYjYzOGZhNTBlNjY4YWZjYjE2MWE4OGQ2MWFmOWM1YzdlNmVmZWM4
15
+ NmEzYjcyOGYzZDI3MjlmOGY0MjRlOTJlN2E1OGI4YzZlZjkxZjc=
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- simple_params (1.0.1)
4
+ simple_params (1.0.2)
5
5
  activemodel (>= 3.0, < 5.0)
6
6
  shoulda-matchers (~> 2.8)
7
7
  virtus (>= 1.0.0)
@@ -149,6 +149,22 @@ module SimpleParams
149
149
  alias_method :original_hash, :original_params
150
150
  alias_method :raw_params, :original_params
151
151
 
152
+ def to_hash
153
+ hash = {}
154
+ # self.class.defined_attributes.each_pair do |key, opts|
155
+ # hash[key.to_sym] = send(key)
156
+ # end
157
+ attributes.each do |attribute|
158
+ if send(attribute).is_a?(SimpleParams::Params)
159
+ hash[attribute] = send(attribute).to_hash
160
+ else
161
+ hash[attribute] = send(attribute)
162
+ end
163
+ end
164
+
165
+ hash
166
+ end
167
+
152
168
  # Overriding this method to allow for non-strict enforcement!
153
169
  def method_missing(method_name, *arguments, &block)
154
170
  if strict_enforcement?
@@ -1,3 +1,3 @@
1
1
  module SimpleParams
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
@@ -51,6 +51,25 @@ describe SimpleParams::Params do
51
51
  end
52
52
  end
53
53
 
54
+ describe "to_hash", to_hash: true do
55
+ it "returns params hash" do
56
+ params = AcceptanceParams.new(name: "Tom", address: { "street" => "1 Main St."} )
57
+ params.to_hash.should eq({
58
+ reference: nil,
59
+ name: "Tom",
60
+ age: nil,
61
+ color: "red",
62
+ address: {
63
+ street: "1 Main St.",
64
+ city: nil,
65
+ zip_code: nil,
66
+ state: "North Carolina",
67
+ company: nil
68
+ }
69
+ })
70
+ end
71
+ end
72
+
54
73
  describe "nested_class", nested_class: true do
55
74
  it "names nested class correctly" do
56
75
  nested = AcceptanceParams.new.address
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_params
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - brycesenz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-17 00:00:00.000000000 Z
11
+ date: 2015-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel