Jay McGavren's Journal

2009-01-11

Extlib for everyday use...

Looks like a couple of my core enhancements may be reinventing the Extlib wheel, so…

irb(main):002:0> "foo\nbar".compress_lines
NoMethodError: compress_lines not defined
  from /Users/jay/ruby/lib/utility/enhancements.rb:12:in `method_missing'
  from (irb):2
irb(main):003:0> exit

FAIL. A tweak to DeferredActiveSupport (now DeferredExtensions)…

-module DeferredActiveSupport
+module DeferredExtensions
   def method_missing(method, *arguments, &block)
     require 'activesupport'
+    require 'extlib'

 class String

-   include DeferredActiveSupport
+   include DeferredExtensions

#And other classes...

And retry:

jay@dandelion:~
$ /Users/jay/Shortcuts/ruby\ shell
irb(main):001:0> "foo\nbar".compress_lines
=> "foo bar"

Yay! I don’t even know everything I’ve gained yet. Time to play around a bit.

comments powered by Disqus