datts_right 0.0.29 → 0.0.30
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.
- data/Gemfile.lock +1 -1
- data/VERSION +1 -1
- data/datts_right.gemspec +1 -1
- data/lib/datts_right/instance_methods.rb +5 -2
- data/spec/datts_right/update_definition_spec.rb +8 -0
- metadata +3 -3
data/Gemfile.lock
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.30
|
data/datts_right.gemspec
CHANGED
@@ -182,13 +182,16 @@ module DattsRight
|
|
182
182
|
def update_definition(key, new_values={})
|
183
183
|
if dynamic_attributes_options[:definition]
|
184
184
|
if definition && definition[key]
|
185
|
-
attr_key = new_values[:attr_key]
|
185
|
+
attr_key = new_values.symbolize_keys[:attr_key]
|
186
186
|
new_values.each do |k, v|
|
187
|
-
definition[key][k] = v unless k.
|
187
|
+
definition[key][k] = v unless k.to_s == "attr_key"
|
188
188
|
end
|
189
189
|
|
190
|
+
#puts "attr_key is #{attr_key}"
|
190
191
|
if attr_key
|
192
|
+
#puts "Adding definition: #{attr_key} => #{definition[key]}"
|
191
193
|
add_definition(attr_key, definition[key])
|
194
|
+
#puts "Removing definition: #{key} => #{definition[key]}"
|
192
195
|
remove_definition(key)
|
193
196
|
end
|
194
197
|
else
|
@@ -12,6 +12,14 @@ describe DattsRight, ".update_definition(key, value)" do
|
|
12
12
|
c.definition[:robot].should be_nil
|
13
13
|
c.definition[:bodi].should == {:object_type => "string"}
|
14
14
|
end
|
15
|
+
|
16
|
+
it "should update attr_key of a definition even if it's not symbolized" do
|
17
|
+
c = Category.create
|
18
|
+
c.definition = {:robot => {:object_type => "string"}}
|
19
|
+
c.update_definition(:robot, "attr_key" => "bodi")
|
20
|
+
c.definition[:robot].should be_nil
|
21
|
+
c.definition[:bodi].should == {:object_type => "string"}
|
22
|
+
end
|
15
23
|
|
16
24
|
it "should be able to update the rest (all except attr_key) of the definition" do
|
17
25
|
c = Category.create
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: datts_right
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 35
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 30
|
10
|
+
version: 0.0.30
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ramon Tayag
|