The Real Adam Always course correcting

Posted
6 June 2008 @ 1pm

In
Code, Tumblin'

Fake Rails environment

For testing some bits inside of ActiveRecord proper.

  1. module Rails
  2.   def self.env
  3.     o = Class.new do
  4.       def production?
  5.         true
  6.       end
  7.     end
  8.     o.new
  9.   end
  10. end

Evil and fun. Uses `Class.new`, my favorite Ruby method.

Muahahaha.


2 Comments

Posted by
Eric Hodel
6 June 2008 @ 4pm

But you can do it without the Class.new:

o = Object.new
def o.production?() true end
 o


Posted by
Adam Keys
7 June 2008 @ 4pm

Well done. But, I say, what’s the fun in that? ;)


Leave a Comment

Comments will be sent to the moderation queue.

Oh, The Fail I’ve Known Microsoft’s spin on memcached

Flickr View All » RubyConf Notes #3RubyConf Notes #2RubyConf Notes #1RubyConf Notes #0Dogs in the morningMy Day, YesterdayGetting aroundMolly loungingasdfjkl;