# Method\_missing

**URL:** <https://www.ruby-forum.com/t/method-missing/195747>\
**Category:** Ruby\
**Created:** [September 29, 2010, 1:23pm UTC](https://www.ruby-forum.com/t/method-missing/195747 "2010-09-29T13:23:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![simon780](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/82dd89/32.png) [@simon780](https://www.ruby-forum.com/u/simon780)\
**Post date:** [September 29, 2010, 1:23pm UTC](https://www.ruby-forum.com/t/method-missing/195747/1 "2010-09-29T13:23:25Z")

</div>

Hi, I have extended BDI::Row as below in order to use dot notation to  
retrieve columns values from result rows. It seems however that some  
methods  
like inspect for example now get caught as missing by this hook and are  
not  
found and executed as expected. Could anyone shed any light on this  
behaviour please?

class DBI::Row  
def method\_missing(name, \*args)  
puts “method missing #{name}”  
result = by\_field(name)  
end  
end

simon

---

<div class="post-metadata">

**Author:** ![simon780](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/82dd89/32.png) [@simon780](https://www.ruby-forum.com/u/simon780)\
**Post date:** [September 29, 2010, 1:35pm UTC](https://www.ruby-forum.com/t/method-missing/195747/2 "2010-09-29T13:35:08Z")

</div>

On Wed, Sep 29, 2010 at 1:22 PM, Simon C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> end  
> end
> 
> simon

Are you talking about Ruby/DBI?

[http://ruby-dbi.rubyforge.org/git?p=ruby-dbi.git;a=blob;f=lib/dbi/row.rb;h=dcf40396ee59c6cf36ab9fec937f38f012570e4d;hb=HEAD](http://ruby-dbi.rubyforge.org/git?p=ruby-dbi.git;a=blob;f=lib/dbi/row.rb;h=dcf40396ee59c6cf36ab9fec937f38f012570e4d;hb=HEAD)

DBI::Row uses DelegateClass to delegate some of the behaviour to an  
Array. Right now I’m not really sure how DelegateClass works  
underneath, but it seems your overriding of method\_missing is messing  
with it.

Sorry, I don’t have a solution right now.

Jesus.

---

<div class="post-metadata">

**Author:** ![simon780](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/82dd89/32.png) [@simon780](https://www.ruby-forum.com/u/simon780)\
**Post date:** [September 29, 2010, 1:38pm UTC](https://www.ruby-forum.com/t/method-missing/195747/3 "2010-09-29T13:38:39Z")

</div>

ahh interesting - i’ll look into that, thanks - my first attempt  
at meta-programming so still a lot to learn

2010/9/29 JesÃºs Gabriel y GalÃ¡n [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![simon780](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/82dd89/32.png) [@simon780](https://www.ruby-forum.com/u/simon780)\
**Post date:** [September 29, 2010, 3:38pm UTC](https://www.ruby-forum.com/t/method-missing/195747/4 "2010-09-29T15:38:39Z")

</div>

Thanks JesÃºs, the following seems to work

class DBI::Row  
def method\_missing(name, \*args, &block)  
return **getobj**.send(name, \*args, &block) if  
**getobj**.respond\_to?(name)  
result = by\_field(name)  
end  
end
