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
1
vote
1 answer

ActionMailer method missing "default_url_setting"

When I run my rails app in development mode, it runs fine. When I run it in production mode, though, it crashes on launch, and I get this output from the…
Mason
  • 6,893
  • 15
  • 71
  • 115
1
vote
1 answer

Can anyone explain this Ternary and the method_missing part of the code?

class Numeric @@currencies = {'yen' => 0.013, 'euro' => 1.292, 'rupee' => 0.019, 'dollar' => 1.0} def method_missing(method, *args) singular_currency = (method == :in ? args.first : method).to_s.gsub(/s$/, '') if…
1
vote
3 answers

How do I delegate methodMissing calls to nested classes?

I'd like to create a DSL with syntax like: Graph.make { foo { bar() definedMethod1() // isn't missing! } baz() } Where when the handler for this tree encounters the outermost closure, it creates an instance of some…
Mark Elliot
  • 75,278
  • 22
  • 140
  • 160
1
vote
3 answers

Redefine nil in smalltalk to respond any message

I want to redefine smalltalk's nil to work like the one in objective-c. So when nil receives a message that it can't handle, it returns nil. Now I know that nil is just a shortcut for UndefinedObject but is there anything like method_missing in Ruby…
Uko
  • 13,134
  • 6
  • 58
  • 106
0
votes
2 answers

Ruby - ArgumentError: wrong number of arguments (2 for 1)

I have the following class overwrite: class Numeric @@currencies = {:dollar => 1, :yen => 0.013, :euro => 1.292, :rupee => 0.019} def method_missing(method_id) singular_currency = method_id.to_s.gsub( /s$/, '').to_sym if…
8vius
  • 5,786
  • 14
  • 74
  • 136
0
votes
0 answers

after uninstall a package i get the error: missing gradle project configuration folder:.setting java(0)

click to see the problem I receive the error when I uninstalled react-native-youtube and react-native-video thos two packages. "npm uninstall react-native-youtube --no--save", "npm uninstall react-native-video --no--save" I Uninstalled those package…
0
votes
1 answer

Conditionally filling missing data based on other variables in R

enter image description here sorry for adding the screenshot, I download data from https://www.kaggle.com/datasets/rikdifos/credit-card-approval-prediction Can someone inform me about the way to fill those NA values that the occupation column has? I…
0
votes
1 answer

No macro for Power Query in Excel 2013

I installed "Power Query" in Excel 2013. Works fine. However it doesn't support VBA. No code is generated when I try to make a macro with the macro recorder. What I am doing wrong?
John
  • 1
  • 1
0
votes
1 answer

Rspec - Argument error after overwriting method_missing and respond_to_missing

I have a controller that i want to write rspec for results_controller.rb class Api::V1::ResultsController < Api::V1::ApplicationController before_action :devices include DataHelper def show results = get_dr_results render json: {…
Suganya Selvarajan
  • 962
  • 1
  • 11
  • 33
0
votes
1 answer

Implement method_missing in Rails

I'm using the OMDB API to learn about using 3rd Party apis in Rails. I've setup my app so all I have to input is the movie title and 6 other attributes get populated from the OMDB API. All of the method calls to retrieve the data from the api are…
hashrocket
  • 2,210
  • 1
  • 16
  • 25
0
votes
1 answer

missing parameter type scala

I typed the following in scala: def count(e: Int, list: List[Int]): Int = list.foldLeft(e)((sum) => list match { case x::xs if e == x => sum = sum + 1 case Nil => sum }) Why am I getting an error on the second Line…
0
votes
3 answers

method_missing and association_proxy in rails

So, here's my problem. I currently am building a simple authentication system for a rails site. I have 3 classes for this: Person, Session, and Role. In my Person model I have defined method_missing to dynamically capture roles according to this…
Trevor
  • 1
0
votes
1 answer

Throw custom exception in `method_missing` without calling .new

I'm redefining method_missing for a proxy-style object. I would like to be able to throw a custom NoMethodError (or some other error if NoMethodError is a particular problem, I used an ArgumentError below) to give the caller more information as to…
0
votes
1 answer

Xamarin c# SetLooping missing

I'm novice in programming and this is my first project ever in c# xamarin. I want to set loop on that MediaPlayer but SetLooping method is missing in Android.Media. I'm using Visual Studio 2017 Community. Here is my code. Thanks in advance for any…
bariks
  • 3
  • 1
0
votes
1 answer

Difference between calling method_missing in Ruby with and without parentheses

Is there any possibility to establish in method_missing declaration in Ruby whether a given missing_method was called (without any arguments) using parentheses notation, ie: foo.non_existing_method() or using parentheses-less…
mgamer
  • 13,580
  • 25
  • 87
  • 145
1 2 3
8 9