Questions tagged [method-missing]

The Ruby method that is invoked on an object when you send it a message (or call a method) that it doesn't understand.

The method_missing method is used to respond to methods when you don't know what methods you need to understand until runtime.

124 questions
0
votes
2 answers

Rails Method_missing to throw back values from a hash

i am trying to write a method_missing method, so that when i run a method it must hit the hash and look at the keys, if it finds a match to return the value. and continue. the hash is populated from a sql query that i wrote so the values are never…
legendary_rob
  • 12,792
  • 11
  • 56
  • 102
-1
votes
1 answer

Method_missing works, but const_missing does not work

I have a simple ruby function: module MyModule def foo(param) puts param end end I want to be able to make calls with undefined tokens like bar and Baz, as follows: foo bar foo Baz Note that I need to be able to pass any token name…
Anand
  • 3,690
  • 4
  • 33
  • 64
-2
votes
1 answer

How can I get Ruby 2.1.5 to report an object's class for a missing method error?

This line: @page = @page.launch_profile(@profile_name) is causing this error: undefined method `launch_profile' for # (NoMethodError) If I add puts "Page = #{@page} "{@page.class}" immediately before the call that…
android.weasel
  • 3,343
  • 1
  • 30
  • 41
-4
votes
1 answer

How does overriding `method_missing` work?

o = Object.new def o.method_missing(m,*args) puts "xxxxxxx #{m}" end p o.some_method What is the underlying process of overriding a method?
Mor Haham
  • 49
  • 1
  • 8
1 2 3
8
9