Where is the send() function?

Hi,

in the tutorial “4 Days on Rails” the following code fragment is used:

,----
| <% for column in Category.content_columns %>
| <%=h category.send(column.name) %>
| <% end %>
`----

Apparently, the send() function returns the column value by name, but
where does this function comes from? Unfortunately, neither the tutorial
nor the API documentation tell it.


\ / [email protected]
/lad http://www.hashbang.de

http://www.ruby-doc.org/docs/ProgrammingRuby/html/ref_c_object.html#Object.send

On Feb 1, 2006, at 9:37 AM, Gael P. wrote:

Apparently, the send() function returns the column value by name, but
where does this function comes from? Unfortunately, neither the
tutorial
nor the API documentation tell it.

Programming Ruby: The Pragmatic Programmer's Guide
ref_c_object.html#Object.send

No need to search the web:

$ ri send
------------------------------------------------------------ Object#send
obj.send(symbol [, args…]) => obj
obj.send(symbol [, args…]) => obj

  Invokes the method identified by _symbol_, passing it any

arguments
specified. You can use +send+ if the name +send+ clashes with
an existing method in obj.

     class Klass
       def hello(*args)
         "Hello " + args.join(' ')
       end
     end
     k = Klass.new
     k.send :hello, "gentle", "readers"   #=> "Hello gentle readers"


Eric H. - [email protected] - http://segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com

Vlad Berditchevskiy wrote:

Hi,

in the tutorial “4 Days on Rails” the following code fragment is used:

,----
| <% for column in Category.content_columns %>
| <%=h category.send(column.name) %>
| <% end %>
`----

Apparently, the send() function returns the column value by name, but
where does this function comes from? Unfortunately, neither the tutorial
nor the API documentation tell it.


\ / [email protected]
/lad http://www.hashbang.de

Consider this:

-1.send(“abs”)

send and send are methods on the Object class in Ruby.

“Invokes the method identified by symbol, passing it any arguments and
block.”

Bob S.
http://www.railtie.net/