datts_right 0.0.26 → 0.0.27
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -2
- data/VERSION +1 -1
- data/datts_right.gemspec +1 -1
- data/lib/datts_right/instance_methods.rb +10 -0
- data/spec/datts_right/add_definition_spec.rb +7 -0
- metadata +3 -3
data/Gemfile.lock
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.27
|
data/datts_right.gemspec
CHANGED
@@ -127,6 +127,16 @@ module DattsRight
|
|
127
127
|
key = key.to_sym
|
128
128
|
#puts "add_definition(:#{key}, #{value.inspect}). current definition: #{definition.nil?}"
|
129
129
|
if dynamic_attributes_options[:definition]
|
130
|
+
#puts ":definition is true, so let's see if definition[:#{key}] already exists"
|
131
|
+
# Checking definition straight seems to cause a problem. Is this a bug with Rails?
|
132
|
+
# The problem was like this (assuming definition was actually nil):
|
133
|
+
# definition.nil? # false
|
134
|
+
# definition.inspect # nil
|
135
|
+
# definition.class.name # NilClass
|
136
|
+
#
|
137
|
+
# How in the world can .nil? return false when it was nil??
|
138
|
+
dynamic_attribute_definition.definition ||= {}
|
139
|
+
|
130
140
|
if definition[key]
|
131
141
|
raise AlreadyDefined, "#{key} is already defined"
|
132
142
|
else
|
@@ -28,4 +28,11 @@ describe DattsRight, ".add_definition(key, value)" do
|
|
28
28
|
it "should raise AttributeKeyRequired if no attr_key is passed" do
|
29
29
|
lambda {Page.create.add_definition(nil, {})}.should raise_error(DattsRight::AttributeKeyRequired)
|
30
30
|
end
|
31
|
+
|
32
|
+
it "should be able to handle if definition is nil" do
|
33
|
+
c = Category.create
|
34
|
+
c.definition = nil
|
35
|
+
c.save
|
36
|
+
lambda {c.add_definition(:real, :object_type => "string")}.should_not raise_error(NoMethodError)
|
37
|
+
end
|
31
38
|
end
|
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: 41
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 27
|
10
|
+
version: 0.0.27
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ramon Tayag
|