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
2
votes
4 answers

How to find jar cointainign a given class

I got an error for missing class "org.apache.xerces.impl.XMLDocumentFragmentScannerImpl". It is a new project setup, whitout employ maven or other tool to manage dependencies. I think to forgot to include some jar, how to find what jar own…
zeppaman
  • 844
  • 8
  • 23
2
votes
2 answers

Rails Method Missing - How can I get a backtrace of 'else' case?

I have a model that references and instance variable that is an instance of another class. I would like to delegate missing methods to that variable like this: def method_missing(method_name, *args, &block) if…
Eric H.
  • 6,894
  • 8
  • 43
  • 62
2
votes
5 answers

Erlang and method_missing

I come from a Java and Ruby background and I was wondering if there is any equivalent of "method_missing" in Erlang. I have looked at the documentation and the closest I can see is the use of erl_eval and erl_parse, but I wanted to know if there is…
yazz.com
  • 57,320
  • 66
  • 234
  • 385
2
votes
1 answer

'method_missing': undefined local variable or method 'has_ancestry'

I am following this tutorial (http://www.tweetegy.com/2013/04/create-nested-comments-in-rails-using-ancestry-gem/) on how to setup the Ancestry gem for nested comments. When I run through the tutorial on a normal rails app it works fine. My issue…
2
votes
1 answer

method_missing visibility in Ruby

method_missing shows up in Object.private_methods, not in Object.public_methods. However, when I call Object.method_missing :stupidmethod, I get NoMethodError: undefined method `stupidmethod' for Object:Class I would expect to get NoMethodError:…
mziwisky
  • 335
  • 1
  • 12
2
votes
2 answers

Metaprogramming: method_missing and __send__

I've found an oddness in Ruby. Using method_missing/respond_to_missing? to dynamically handle method calls initiated via __send__ fails when Kernel defines the same method: class Testerize def method_missing(method, *args, &block) if method…
Irongaze.com
  • 1,639
  • 16
  • 22
2
votes
1 answer

How to correct missing class/method issue with Proguard.cfg

I have a fairly large project that uses some reflection in the code. The line of code that is causing the following crash: W/System.err(22122): java.lang.NoSuchMethodException: [class com.DynaZu.Tracker.cd] W/System.err(22122): at…
JoelParke
  • 2,676
  • 2
  • 24
  • 38
2
votes
1 answer

No parameterless constructor defined for this object.

Currently I've got a runtime exception: 'Systen.MissingMethodException : No parameterless constructor defined for this object. I've googled and came across a lot of people actually not having a default contstructor, though my code actually does, so…
1
vote
1 answer

How to alternatively access accessors as array indices?

I have a class Foo which has several methods like button_0_0, button_0_1, button_0_2, button_1_0, etc. I would like to be able to access these alternatively via the following syntax: foo.button[0][1] foo.button[1][2] # etc. I know I could just…
gabriel
  • 1,787
  • 2
  • 19
  • 24
1
vote
2 answers

Object.respond_to? stuck in infinite loop

I'm building a Rails 3 gem that essentially modifies the records returned from an ActiveRecord query. One of the things I'm doing is overriding the method_missing and respond_to? methods, but it seems that my respond_to? definition is resulting in…
Matt Huggins
  • 81,398
  • 36
  • 149
  • 218
1
vote
2 answers

Single method_missing for Array, Hash and Range

I am new to Ruby. Is there a way to write a single 'def Array/Range/Hash' with a method_missing that will work for all Ranges, Arrays and Hash i.e. all Enumerables? For e.g. the following should work: [1..5].Sum() [1,2,3,5].Sum() {'x' => 1,…
A9S6
  • 6,575
  • 10
  • 50
  • 82
1
vote
2 answers

sp R package and missing values

I am trying to create a bubble plot in R using the sp package. My data has a lot of missing values ("N/A") and the bubble plot does not seem to like it. library(sp) X<-runif(100, min=0, max=1000) Y<-runif(100, min=0,…
LoveMeow
  • 1,141
  • 2
  • 15
  • 26
1
vote
3 answers

android camera (froyo) doesnt include static method open()

I must be the first to face this problem because I can't find even a single thread about it. Today I wanted to start on the camera aspect of my application needs. I read up some documentation my manifest looks like this:
Joey Roosing
  • 2,145
  • 5
  • 25
  • 42
1
vote
2 answers

Row wise concatenation and replacing nan with common column values

Below is the input data df1 A B C D E F G Messi Forward Argentina 1 Nan 5 6 Ronaldo Defender Portugal Nan 4 Nan 3 Messi Midfield Argentina Nan 5 Nan 6 Ronaldo Forward Portugal 3 Nan 2 3 Mbappe …
AB14
  • 397
  • 2
  • 13
1
vote
0 answers

Comparing two models with different majority classes

I calculated the accuracy for a model with listwise deletion (0.75) and for a multiple imputation model (0.67). It seems like the standard model performs better. However, the naive baseline of the standard model is 70% (the majority class is 70% of…
1 2 3
8 9