# Catch all method... e.g perl's autoload

**URL:** <https://www.ruby-forum.com/t/catch-all-method-e-g-perls-autoload/67356>\
**Category:** Ruby\
**Created:** [September 2, 2006, 7:02pm UTC](https://www.ruby-forum.com/t/catch-all-method-e-g-perls-autoload/67356 "2006-09-02T19:02:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tim\_McIntyre](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7bcc69/32.png) [@Tim\_McIntyre](https://www.ruby-forum.com/u/Tim_McIntyre)\
**Post date:** [September 2, 2006, 7:02pm UTC](https://www.ruby-forum.com/t/catch-all-method-e-g-perls-autoload/67356/1 "2006-09-02T19:02:45Z")

</div>

Hey all,

Does ruby have a catchall method similar to perl’s autoload?

Thanks in advance!  
Tim

Be who you are and say what you feel, because those who mind don’t  
matter and those who matter don’t mind.

- Dr. Seuss

---

<div class="post-metadata">

**Author:** ![Tim\_McIntyre](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7bcc69/32.png) [@Tim\_McIntyre](https://www.ruby-forum.com/u/Tim_McIntyre)\
**Post date:** [September 2, 2006, 7:16pm UTC](https://www.ruby-forum.com/t/catch-all-method-e-g-perls-autoload/67356/2 "2006-09-02T19:16:47Z")

</div>

On Sep 2, 2006, at 10:02 AM, Tim McIntyre wrote:

> Does ruby have a catchall method similar to perl’s autoload?

Does this sound right?

## $ ri Kernel#method\_missing -------------------------------------------------- Kernel#method\_missing obj.method\_missing(symbol [, \*args] ) =\> result

```
  Invoked by Ruby when obj is sent a message it cannot handle.
  symbol is the symbol for the method called, and args are any
  arguments that were passed to it. By default, the interpreter
  raises an error when this method is called. However, it is
  possible to override the method to provide more dynamic behavior.
  The example below creates a class Roman, which responds to methods
  with names consisting of roman numerals, returning the
  corresponding integer values.

     class Roman
       def romanToInt(str)
         # ...
       end
       def method_missing(methId)
         str = methId.id2name
         romanToInt(str)
       end
     end

     r = Roman.new
     r.iv #=> 4
     r.xxiii #=> 23
     r.mm #=> 2000

```

–  
Eric H. - removed\_email\_address@domain.invalid - [http://blog.segment7.net](http://blog.segment7.net)  
This implementation is HODEL-HASH-9600 compliant

[http://trackmap.robotcoop.com](http://trackmap.robotcoop.com)

---

<div class="post-metadata">

**Author:** ![Tim\_McIntyre](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7bcc69/32.png) [@Tim\_McIntyre](https://www.ruby-forum.com/u/Tim_McIntyre)\
**Post date:** [September 2, 2006, 8:10pm UTC](https://www.ruby-forum.com/t/catch-all-method-e-g-perls-autoload/67356/3 "2006-09-02T20:10:54Z")

</div>

Yep, thats what I was looking for. Thanks Eric!

still have some ActiveRecord idiosyncrasies holding up what I want to  
do here but thats the gist.

Thanks again!  
Tim

On Sep 2, 2006, at 10:15 AM, Eric H. wrote:

> –  
> class Roman  
> r.iv #=\> 4

Be who you are and say what you feel, because those who mind don’t  
matter and those who matter don’t mind.

- Dr. Seuss
