Commit 2eb4301ba4563ce078231185ec2603b6f96d419f

Bugfixes for callback stuff (when_slot_not_found behaves properly now)

Commit diff

strokedb-ruby/lib/document/document.rb

 
267267 send(:[]=,sym.chomp('='),*args)
268268 else
269269 unless slotnames.include?(sym)
270 raise SlotNotFoundError.new(sym) if (callbacks[:when_slot_not_found]||[]).empty?
270 raise SlotNotFoundError.new(sym) if (callbacks['when_slot_not_found']||[]).empty?
271271 execute_callbacks(:when_slot_not_found,sym)
272 else
273 send(:[],sym)
272274 end
273 send(:[],sym)
274275 end
275276 end
276277
toggle raw diff

strokedb-ruby/spec/document/document_spec.rb

 
2323
2424
2525 it "should call when_slot_not_found callback on missing slot" do
26 @document.callbacks[:when_slot_not_found] = [mock("callback")]
27 @document.should_receive(:execute_callbacks).with(:when_slot_not_found,'slot_that_surely_does_not_exist')
28 @document.slot_that_surely_does_not_exist
26 @document.callbacks['when_slot_not_found'] = [mock("callback")]
27 @document.should_receive(:execute_callbacks).with(:when_slot_not_found,'slot_that_surely_does_not_exist').and_return("Yes!")
28 @document.slot_that_surely_does_not_exist.should == "Yes!"
2929 end
3030
3131 it "should raise an exception if slot not found when trying to read it" do
toggle raw diff