Posted by Peter Morris
Wed, 30 Apr 2008 13:45:00 GMT
Ok, so I have been using to_xml to handle generating xml serialised lists for a restful xml interface.
I came across this interesting situation.
If you are serialising a collection which is implemented as a set of subclasses using STI, the to_xml will generate different xml depending on which class of items it sees first.
For instance, if you start the list with an instance of the base class, it will generate a list encapsulated with the plural name of the class name, and each element will be a singular of the class name for the base class, irrespective of which classes each of the objects are.
BUT, if the first item in the list is one of the subclasses, the to_xml call will see that it is a heterogenious list (presumably because the successive items don’t all return ‘true’ for .kind_of? of the class of the first item, and will generate a xml list encapsulated as <record> entities within a <records> list.
Oh, that makes me SOO happy.
Posted in Coding | Tags coding, rails, xml | no comments
Posted by Peter Morris
Wed, 23 Apr 2008 13:01:00 GMT
“A software developer is in the unhappy state that by the time he knows everything he needs to start work, he has probably finished”
Who said that?
Peter Morris, 2008.
Posted in Coding | no comments
Posted by Peter Morris
Thu, 17 Apr 2008 13:20:00 GMT
I don’t need to buy any fiction books anymore. Nor go to the cinema.
All of my dramatic needs are met, simply by reading my email.
I received this message from a young lady requesting my assistance with the following tale….
—-—-—-—-—-—-—-—-—-——
From Miss Anna Camara,
l know this mail will come as a surprise to you. however is not mandatory nor will I in any manner compel you to honor against your will. Your profile pushed me to send you this mail, I am Miss Anna Camara,, I am 22years old single woman, the only child and the only daughter of my late parents Mrs. Emmanuel Camara. My father was a highly reputable farmer (a cocoa merchant) in cote d’ ivories during his days.
It is sad to say that he was poisoned and passed away mysteriously in France during one of his business trips abroad on 12th. May 2007.Though his sudden death was linked or rather suspected to have been masterminded by my uncle who traveled with him at that
time. But God knows the truth! My mother died when I was just 4 years old, and since then my father took me so special until his death.
Before he made the trip to France that lead to my misfortune (his death) He called me and explained to me the reason why he will make this trip and also told me that he deposited a trunk box that contain $6, 500.000 ( Six million Five hundred thousand usdollars) in a Security company here in Abidjan Ivory Coast and that this money is for an investment purpose overseas.
After the burial of my father, That my uncle whom I suspected over the death of my father was against me, He is looking for a way to kill me so that he will claim all my fathers properties. Right now I am living in the church and I am not feeling comfortable because of my condition.
Now l need your assistance to move this fund to your country for investment as that has been my late father’s aim before his death. Now permit me to ask you these few questions:
Can you honestly help me receive this fund in your country?
When you receive this fund in your country, what percentage will you like to take from the fund for assisting me?
Are you willing to help me to pay if there is any charges that might involve during the processing of the fund to your country? If this proposal arose your
interest kindly contact me back through this my email address ( anna_camara26@yahoo.com )
Thanks and God bless you.
Your Sincerely one,
Miss Anna Camara.
—-—-—-—-—-—-—-—-—-—-——-
Amazing. The drama, the suspense… Will her uncle do her in! will the heroine escape? who can tell.
Tags junkmail, nigerian_scam | no comments
Posted by Peter Morris
Wed, 16 Apr 2008 07:53:00 GMT
There is really nothing I can say about this….
Just, go there, go there NOW, and read.
Posted in Coding | Tags coding, funny, insightful, quotes | no comments
Posted by Peter Morris
Mon, 14 Apr 2008 07:18:00 GMT
I am quite a proponent of TDD/BDD, my framework of choice being RSPEC within Rails
But, I also understand that for people unused to TDD, the upfront investment seems daunting. So, I was very interested to be told about…
DOCTEST
This seems to be a nice light introduction into TDD. I can see that for extensive test coverage it is going to be a bit of a problem, there being no concept of fixtures etc. But I can definitely see someone adopting DOCTEST and then moving on to Unit testing or RSPEC later.
If you do not already embrace TDD, and recoil at its apparent heaviness, give doctest a look, but remember, tdd can be habit forming.
Posted in Coding | Tags bdd, coding, rails, tdd | no comments
Posted by Peter Morris
Fri, 04 Apr 2008 07:03:00 GMT
I like RSPEC, I LOVE RSPEC. But, this morning, I found a flaw in its beauty.
If you are using a lambda to verify that a block of code raises an exception it works fine.
A problem occurs if you are using a lambda like….
lambda {
... do some stuff …
}.should_not raise_error(SomeSpecificErrorClass)
to check that an error of that type is not raised.
The problem is, that the ‘raise_error’ will trap errors looking for the specific type of error you are asking for, but, in doing so, it only takes notice of the specific type of error you mention, and traps but ignores all others. So, if an expectation within the block fails, this will not be reported.
Significant problem!
Posted in Coding | Tags rspec, ruby | no comments