Caius Theory

Now with even more cowbell…

Inaugural Habaricon

So I managed to secure a place to HabariCon '08. Not quite sure what to expect, but being able to meet other people in real life and talk about habari & related things all day will be quite cool.

Expect a round-up post of the 'con tonight!

Another Concise Code Example

This is just another example showing how I refactor code down to its bare minimum. The reason why I do this so much (and indeed I think why ruby is so easy to read compared to other languages) is because it makes my code more readable and less of a bugger to pick up after a while.

class Page
  attr_accessor :parent_id
        
  def old_parent
    if self.parent?
      Page.find( self.parent_id )
    else
      false
    end
  end

  def parent
    return Page.find( self.parent_id ) if self.parent?
    false
  end
    
end

old_parent and parent return exactly the same, but one is 2 lines compared to 5 and easier to read.

Update: Ciaran pointed out that the Page.parent method would only ever return false. Added the return statement to it to fix the bug.