12 Aug '12, 7am

Jeff Dean's Ruby Blog - DelegateClass rocks my world

If you notice that your classes have more than one responsibility, you can easily split them up into multiple, more cohesive classes using Ruby's DelegateClass. Let's say that you have a Person class, and that people in your system can sell things and/or publish articles. You can't use subclasses, because a person can be an author and a seller at the same time. At first you might start with something like this: class Person < ActiveRecord::Base has_many :articles has_many :comments, :through => :articles has_many :items has_many :transactions def is_seller? items.present? end def amount_owed # => some fancy math end def is_author? articles.present? end def can_post_article_to_homepage? # => some fancy permissions end end This might seem OK at first. You might say "Well, it's the responsibility of Person to know about both the items they've sold, as well as the articles the...

Full article: http://pivotallabs.com/users/jdean/blog/articles/1138-del...

Tweets

#Ruby on the surface is such a simple language ...

ruby-lang.org 11 Aug '12, 6am

Instance variables are hidden away inside the object. They’re not terribly hidden, you see them whenever you inspect the o...

@ShipoutAlerts The typical route is to use the ...

apidock.com 13 Aug '12, 11pm

This command will create following directories and install files onto them. * ${DESTDIR}${prefix}/bin * ${DESTDIR}${prefix...

Dean's Blog: via @RunnersWorld

dean.runnersworld.com 05 Aug '12, 12pm

For the next two weeks the world turns its attention to the London Olympic Games , a place where the top athletes from aro...

あわせて読みたい:“Rubyist Magazine - Ruby M17N の設計と実装”

jp.rubyist.net 13 Aug '12, 4am

なお、非 ASCII な文字を含むリテラルを magic comment なしに書いていた場合、US-ASCII ではない文字が存在しているとして、invalid multibyte char というエラーになります。これはソースコードの可搬性...

Ruby Downloads:

rubyinstaller.org 12 Aug '12, 12pm

Depending on your location, sometimes the downloads will not work. This is due RubyForge provided mirrors. Until we comple...

Rockin' Ruby Red from @JSCollection

heels.com 13 Aug '12, 5pm

Earn your fashion credentials in this stunner from Jessica Simpson. Waleo brings you a shiny ruby patent leather upper. Th...

Ruby on Rails with CSS Web design by chjoly: I ...

freelancer.com 14 Aug '12, 7pm

Freelancer.com (formerly GetAFreelancer) is the world's largest outsourcing and crowdsourcing marketplace for small busine...