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 +8 -8
- data/Gemfile.lock +1 -1
- data/lib/simple_params/params.rb +16 -0
- data/lib/simple_params/version.rb +1 -1
- data/spec/acceptance_spec.rb +19 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OGYzOTBkMWI1YTA1MmNlZThiMzZiMzE1MGQyN2NlMmM3NTc1NTMwNQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NjExZWE4N2FiMDZhODJiNjM3M2EyNWFmM2E5Yzk4Y2RhNWM4YTk5ZQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MjlmNDFhNzZiMTZlNTI1MDIyZTA3NzZiOGIxNTdjYTg2MTczNTY1OWIzZDY4
|
10
|
+
N2VkMTM5NmU3ZDVmNWNkNzE5ZTRmOWNiMzI2OTM0MmNhYTc1NGFkMDlkMTQ1
|
11
|
+
N2YyOTc3MmRkMjkyNmYwMDQyY2Q4YTJlNDY0MmMzMThhNzBhM2Y=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZmQ2YTBiOWMyYTA4MWYwZmMzNDg2NGJmNTRjNjQwZGVlY2RjY2YwYmYyZGQ1
|
14
|
+
MzIzOGRjYjYzOGZhNTBlNjY4YWZjYjE2MWE4OGQ2MWFmOWM1YzdlNmVmZWM4
|
15
|
+
NmEzYjcyOGYzZDI3MjlmOGY0MjRlOTJlN2E1OGI4YzZlZjkxZjc=
|
data/Gemfile.lock
CHANGED
data/lib/simple_params/params.rb
CHANGED
@@ -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?
|
data/spec/acceptance_spec.rb
CHANGED
@@ -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.
|
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-
|
11
|
+
date: 2015-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|