demeter 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/lib/demeter.rb +1 -1
- data/spec/demeter_spec.rb +8 -0
- metadata +1 -1
data/Rakefile
CHANGED
data/lib/demeter.rb
CHANGED
@@ -21,7 +21,7 @@ module Demeter
|
|
21
21
|
raise NoMethodError if Demeter.demeter_objects[self.class.to_s.to_sym].select { |object| message_split.first.to_sym == object }.length == 0
|
22
22
|
object = self.send(message_split.first)
|
23
23
|
message_split.delete message_split.first
|
24
|
-
object.send(message_split.join("_"))
|
24
|
+
object ? object.send(message_split.join("_")) : nil
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
data/spec/demeter_spec.rb
CHANGED
@@ -214,4 +214,12 @@ describe Demeter do
|
|
214
214
|
instance.person = person
|
215
215
|
instance.person_name.should be_eql("name overrided")
|
216
216
|
end
|
217
|
+
|
218
|
+
it 'Should return nil when demetered object is nil' do
|
219
|
+
AClass.send(:attr_accessor, :person)
|
220
|
+
AClass.demeter :person
|
221
|
+
|
222
|
+
instance = AClass.new
|
223
|
+
instance.person_name.should be_nil
|
224
|
+
end
|
217
225
|
end
|