The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Erb Caching in a Handful

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Red Handed

Posts: 1158
Nickname: redhanded
Registered: Dec, 2004

Red Handed is a Ruby-focused group blog.
Erb Caching in a Handful Posted: Apr 18, 2005 10:46 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Red Handed.
Original Post: Erb Caching in a Handful
Feed Title: RedHanded
Feed URL: http://redhanded.hobix.com/index.xml
Feed Description: sneaking Ruby through the system
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Red Handed
Latest Posts From RedHanded

Advertisement

Dr. Eric Hodel has a brief class for caching compiled ERb templates. The compiled templates aren’t stored on the filesystem—it’s not that kind of cache. It caches the template in an instance variable to prevent recompiling if you’re reusing a template.

Of particular interest to some of you might be his use of method_missing, which our goopy red hands are continually poking around in the dark for.

 def method_missing(action, options = {})
   super unless self.respond_to? "run_#{action}" 

   options.each do |attr, value|
     self.class.send :attr_accessor, attr unless self.respond_to? attr
     self.send "#{attr}=", value
   end

   return self.send("run_#{action}")
 end

Hmm. You’ve got some self.class.send and some self.send. I really think this is an excellent fourteen lines of code for you kids who just got here. Any newbs want to take a stab at explaining?

Read: Erb Caching in a Handful

Topic: RForum 0.1 sees the light of day Previous Topic   Next Topic Topic: Keeping in sync with Typo

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use