Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7068487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:19:47+00:00 2026-05-28T05:19:47+00:00

I understand that method_missing is something of a last resort when Ruby is processing

  • 0

I understand that method_missing is something of a last resort when Ruby is processing messages. My understanding is that it goes up the Object hierarchy looking for a declared method matching the symbol, then back down looking for the lowest declared method_missing. This is much slower than a standard method call.

Is it possible to intercept sent messages before this point? I tried overriding send, and this works when the call to send is explicit, but not when it is implicit.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T05:19:48+00:00Added an answer on May 28, 2026 at 5:19 am

    Not that I know of.

    The most performant bet is usually to use method_missing to dynamically add the method being to a called to the class so that the overhead is only ever incurred once. From then on it calls the method like any other method.

    Such as:

    class Foo
      def method_missing(name, str)
    
        # log something out when we call method_missing so we know it only happens once
        puts "Defining method named: #{name}"
    
        # Define the new instance method
        self.class.class_eval <<-CODE
          def #{name}(arg1)
            puts 'you passed in: ' + arg1.to_s
          end
        CODE
    
        # Run the instance method we just created to return the value on this first run
        send name, str
      end
    end
    
    # See if it works
    f = Foo.new
    f.echo_string 'wtf'
    f.echo_string 'hello'
    f.echo_string 'yay!'
    

    Which spits out this when run:

    Defining method named: echo_string
    you passed in: wtf
    you passed in: hello
    you passed in: yay!
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I understand that any init... method initializes a new object and that NSString stringWithString
Maybe it's useful if calling a method that MyClass doesn't understand on a something
I understand that static method inheritance is not supported in C#. I have also
Am I correct to understand that the abort() method for XMLHttpRequest objects is only
I understand that .NET FileStream's Flush method only writes the current buffer to disk,
I just read Factory Method. I understand that it provides a way to delegate
I understand that these methods are for pickling/unpickling and have no relation to the
I understand that some countries have laws regarding website accessibility. In general, what are
I understand that there are several ways to blend XNA and WPF within the
I understand that they are both supposed to be small, but what are the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.