18 Apr '12, 6am

Shades of Gray: DSL Block Styles:

Posted over 3 years ago in Ruby Tutorials and Ruby Voodoo . There's an argument that rages in the Ruby camps: to instance_eval() or not to instance_eval() . Most often this argument is triggered by DSL discussions where we tend to want code like: configurable.config do width 100 mode :wrap end You can accomplish something like this by passing the block to instance_eval() and changing self to an object that defines the width() and mode() methods. Of course changing self is always dangerous. We may have already been inside an object and planning to use methods from that namespace: class MyObject include Configurable # to get the config() method shown above def initialize config do width calculate_width # a problem: may not work with instance_eval() end end private def calculate_width # the method we want to use # ... end end In this example, if width() comes from a different...

Full article: http://blog.grayproductions.net/articles/dsl_block_styles

Tweets

4 Ways to Get SEO Clients Past Their Content Ma...

searchenginejournal.com 17 Apr '12, 6pm

The number one content marketing problem plaguing many of my clients (and I’m sure other SEO professionals can commiserate...

One of the best Ngau Lam Beef

One of the best Ngau Lam Beef

soshiok.com 17 Apr '12, 1pm

Tai Fatt Hou Cuisine Chong Wah Coffee & Restaurant Block 28 Jalan Bukit Merah (enter from Hoy Fatt Road) Mr Anthony Wong u...

Byers intends to make good on Olympic promise to grandfather

Byers intends to make good on Olympic promise t...

army.mil 18 Apr '12, 11am

SAN ANTONIO (Army News Service, April 17, 2012) -- U.S. Army World Class Athlete Program wrestler Sgt. 1st Class Dremiel B...

Biggest Loser at the Office — Prior Fat Girl: G...

priorfatgirl.com 16 Apr '12, 3pm

I’m participating in this season of our office’s Biggest Loser Challenge. Weigh-Ins will be on Thursday. The accountabilit...

World's biggest Audi showroom coming up in Dubai

World's biggest Audi showroom coming up in Dubai

luxurylaunches.com 16 Apr '12, 2pm

World's biggest Audi showroom coming up in Dubai The world is awaiting the largest display of new Audi vehicles at the Aud...

Is your stuff falling apart? Thank Walmart.

Is your stuff falling apart? Thank Walmart.

grist.org 11 Apr '12, 2pm

Forever in blue jeans, babe? Not anymore. Photo: bburky My friend Tony’s closet is as good a place as any to begin an inve...

Hot for Hartmann: Michigander gets biggest resu...

runblogrun.com 16 Apr '12, 9pm

Boulder resident rebounds from disappointment with the biggest result of his career by Jon Gugala "I am running for myself...

Stanford Robot Block Party Has PR2s, SPHERES, M...

spectrum.ieee.org 13 Apr '12, 8pm

If you couldn't make it to the Robot Block Party at Stanford on Wednesday, you should probably take a minute and seriously...