plain_old_model 0.1.4 → 0.1.5
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 +7 -0
- data/lib/plain_old_model/attribute_assignment.rb +4 -4
- data/lib/plain_old_model/version.rb +1 -1
- data/spec/lib/base_spec.rb +11 -3
- metadata +20 -37
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9297bff31a1a9c7c81a1e680deccc78635a75ef1
|
4
|
+
data.tar.gz: a654e2e11817af53461572c0747ff7b00dbd3c77
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0151bd58b7e8a3f8bd380fc1b3800b9e1fff52faca87417dea9e910dfd3ea94d430f720ee01aa7c26dea496002f34d3fccc71821155ef398d6580edac3b9bdf2
|
7
|
+
data.tar.gz: 64b8ead6435fe72dacc3e2e7793023b5c6a9e50b3e41e6e1987448e3af7fdebc8e200cc37ac21c3ba3b65e30a335c9b31cb0438a77203b7a2d4e7fc0f38a1644
|
@@ -118,7 +118,7 @@ module PlainOldModel
|
|
118
118
|
association_instance = send(attr_name)
|
119
119
|
if association.class == HasOneAssociation
|
120
120
|
instance_hash = create_association_hash(association_instance,{})
|
121
|
-
merged_result = instance_hash.deep_merge(attributes[attr_name])
|
121
|
+
merged_result = instance_hash.with_indifferent_access.deep_merge(attributes[attr_name])
|
122
122
|
elsif association.class == HasManyAssociation
|
123
123
|
association_instance_array = []
|
124
124
|
if association_instance.nil?
|
@@ -126,7 +126,7 @@ module PlainOldModel
|
|
126
126
|
else
|
127
127
|
for i in 0..association_instance.length-1
|
128
128
|
instance_hash = create_association_hash(association_instance[i],{})
|
129
|
-
association_instance_array << instance_hash.deep_merge(attributes[attr_name][i])
|
129
|
+
association_instance_array << instance_hash.with_indifferent_access.deep_merge(attributes[attr_name][i])
|
130
130
|
end
|
131
131
|
merged_result = association_instance_array
|
132
132
|
end
|
@@ -138,9 +138,9 @@ module PlainOldModel
|
|
138
138
|
unless association_instance.nil?
|
139
139
|
association_instance.instance_variables.each do |var|
|
140
140
|
if association_instance.instance_variable_get(var).instance_variables.length > 0
|
141
|
-
association_instance_hash[var.to_s.delete("@")
|
141
|
+
association_instance_hash[var.to_s.delete("@")] = create_association_hash(association_instance.instance_variable_get(var),{})
|
142
142
|
else
|
143
|
-
association_instance_hash[var.to_s.delete("@")
|
143
|
+
association_instance_hash[var.to_s.delete("@")] = association_instance.instance_variable_get(var)
|
144
144
|
end
|
145
145
|
end
|
146
146
|
end
|
data/spec/lib/base_spec.rb
CHANGED
@@ -86,7 +86,7 @@ describe PlainOldModel::Base do
|
|
86
86
|
end
|
87
87
|
it "should not override unassigned nested attributes' values" do
|
88
88
|
@address = Address.new({:fname => "first value", :lname => "second value", :country => {:code => "In", :name => "India", :continent => {:name => "asia", :desc => {:this => "is a test", :actual_desc => "is another test"}}}, :read_test => 'This should be assigned',:write_test => "this shd be available"})
|
89
|
-
@address.assign_attributes({
|
89
|
+
@address.assign_attributes({"fname" => "replaced first value", :lname => "replaced second value", :country => {:name => "United States", :continent => {:desc => {:this => "is a replacement", :actual_desc => "is another replacement"}}}})
|
90
90
|
@address.fname.should == "replaced first value"
|
91
91
|
@address.country.code.should == "In"
|
92
92
|
@address.country.name.should == "United States"
|
@@ -94,8 +94,16 @@ describe PlainOldModel::Base do
|
|
94
94
|
@address.read_test.should == "This should be assigned"
|
95
95
|
end
|
96
96
|
it "should create assigned nested attributes" do
|
97
|
-
@address = Address.new({:
|
98
|
-
@address.assign_attributes({
|
97
|
+
@address = Address.new({:lname => "second value", :read_test => 'This should be assigned',:write_test => "this shd be available"})
|
98
|
+
@address.assign_attributes({"fname" => "first value", :lname => "replaced second value", :country => {:code => "In", :name => "India"} })
|
99
|
+
@address.fname.should == "first value"
|
100
|
+
@address.country.code.should == "In"
|
101
|
+
@address.country.name.should == "India"
|
102
|
+
@address.read_test.should == "This should be assigned"
|
103
|
+
end
|
104
|
+
it "should assigned nested attributes with mixed string and symbol hash keys" do
|
105
|
+
@address = Address.new({:fname => "first value", :lname => "second value", :country => {:code => "", :name => ""}, :read_test => 'This should be assigned',:write_test => "this shd be available"})
|
106
|
+
@address.assign_attributes({:fname => "replaced first value", :lname => "replaced second value", :country => {"code" => "In", "name" => "India"} })
|
99
107
|
@address.fname.should == "replaced first value"
|
100
108
|
@address.country.code.should == "In"
|
101
109
|
@address.country.name.should == "India"
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: plain_old_model
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.5
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Bhaskar Sundarraj
|
@@ -10,90 +9,81 @@ authors:
|
|
10
9
|
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date: 2013-04-
|
12
|
+
date: 2013-04-03 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: activesupport
|
17
16
|
requirement: !ruby/object:Gem::Requirement
|
18
|
-
none: false
|
19
17
|
requirements:
|
20
|
-
- -
|
18
|
+
- - '>='
|
21
19
|
- !ruby/object:Gem::Version
|
22
20
|
version: '0'
|
23
21
|
type: :runtime
|
24
22
|
prerelease: false
|
25
23
|
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
none: false
|
27
24
|
requirements:
|
28
|
-
- -
|
25
|
+
- - '>='
|
29
26
|
- !ruby/object:Gem::Version
|
30
27
|
version: '0'
|
31
28
|
- !ruby/object:Gem::Dependency
|
32
29
|
name: activemodel
|
33
30
|
requirement: !ruby/object:Gem::Requirement
|
34
|
-
none: false
|
35
31
|
requirements:
|
36
|
-
- -
|
32
|
+
- - '>='
|
37
33
|
- !ruby/object:Gem::Version
|
38
34
|
version: '0'
|
39
35
|
type: :runtime
|
40
36
|
prerelease: false
|
41
37
|
version_requirements: !ruby/object:Gem::Requirement
|
42
|
-
none: false
|
43
38
|
requirements:
|
44
|
-
- -
|
39
|
+
- - '>='
|
45
40
|
- !ruby/object:Gem::Version
|
46
41
|
version: '0'
|
47
42
|
- !ruby/object:Gem::Dependency
|
48
43
|
name: rake
|
49
44
|
requirement: !ruby/object:Gem::Requirement
|
50
|
-
none: false
|
51
45
|
requirements:
|
52
|
-
- -
|
46
|
+
- - '>='
|
53
47
|
- !ruby/object:Gem::Version
|
54
48
|
version: '0'
|
55
49
|
type: :development
|
56
50
|
prerelease: false
|
57
51
|
version_requirements: !ruby/object:Gem::Requirement
|
58
|
-
none: false
|
59
52
|
requirements:
|
60
|
-
- -
|
53
|
+
- - '>='
|
61
54
|
- !ruby/object:Gem::Version
|
62
55
|
version: '0'
|
63
56
|
- !ruby/object:Gem::Dependency
|
64
57
|
name: rspec
|
65
58
|
requirement: !ruby/object:Gem::Requirement
|
66
|
-
none: false
|
67
59
|
requirements:
|
68
|
-
- -
|
60
|
+
- - '>='
|
69
61
|
- !ruby/object:Gem::Version
|
70
62
|
version: '0'
|
71
63
|
type: :development
|
72
64
|
prerelease: false
|
73
65
|
version_requirements: !ruby/object:Gem::Requirement
|
74
|
-
none: false
|
75
66
|
requirements:
|
76
|
-
- -
|
67
|
+
- - '>='
|
77
68
|
- !ruby/object:Gem::Version
|
78
69
|
version: '0'
|
79
70
|
- !ruby/object:Gem::Dependency
|
80
71
|
name: rspec-core
|
81
72
|
requirement: !ruby/object:Gem::Requirement
|
82
|
-
none: false
|
83
73
|
requirements:
|
84
|
-
- -
|
74
|
+
- - '>='
|
85
75
|
- !ruby/object:Gem::Version
|
86
76
|
version: '0'
|
87
77
|
type: :development
|
88
78
|
prerelease: false
|
89
79
|
version_requirements: !ruby/object:Gem::Requirement
|
90
|
-
none: false
|
91
80
|
requirements:
|
92
|
-
- -
|
81
|
+
- - '>='
|
93
82
|
- !ruby/object:Gem::Version
|
94
83
|
version: '0'
|
95
|
-
description:
|
96
|
-
|
84
|
+
description: |-
|
85
|
+
This gem is created to cater the projects which do not require a backend/database,
|
86
|
+
but still need some of the niceties offered by the ActiveRecord
|
97
87
|
email:
|
98
88
|
- bhaskar.sundarraj@gmail.combhaskar.sundarraj@gettyimages.com
|
99
89
|
- AppDev_RailGun@gettyimages.com
|
@@ -118,33 +108,26 @@ files:
|
|
118
108
|
- spec/spec_helper.rb
|
119
109
|
homepage: ''
|
120
110
|
licenses: []
|
111
|
+
metadata: {}
|
121
112
|
post_install_message:
|
122
113
|
rdoc_options: []
|
123
114
|
require_paths:
|
124
115
|
- lib
|
125
116
|
required_ruby_version: !ruby/object:Gem::Requirement
|
126
|
-
none: false
|
127
117
|
requirements:
|
128
|
-
- -
|
118
|
+
- - '>='
|
129
119
|
- !ruby/object:Gem::Version
|
130
120
|
version: '0'
|
131
|
-
segments:
|
132
|
-
- 0
|
133
|
-
hash: 3516179471459458128
|
134
121
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
|
-
none: false
|
136
122
|
requirements:
|
137
|
-
- -
|
123
|
+
- - '>='
|
138
124
|
- !ruby/object:Gem::Version
|
139
125
|
version: '0'
|
140
|
-
segments:
|
141
|
-
- 0
|
142
|
-
hash: 3516179471459458128
|
143
126
|
requirements: []
|
144
127
|
rubyforge_project:
|
145
|
-
rubygems_version:
|
128
|
+
rubygems_version: 2.0.3
|
146
129
|
signing_key:
|
147
|
-
specification_version:
|
130
|
+
specification_version: 4
|
148
131
|
summary: This gem is created to cater the projects which do not require a backend/database,
|
149
132
|
but still need some of the niceties offered by the ActiveRecord
|
150
133
|
test_files:
|