Where is the send() function?


#1

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.


\ / removed_email_address@domain.invalid
/lad http://www.hashbang.de


#2

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


#3

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.

http://www.ruby-doc.org/docs/ProgrammingRuby/html/
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. - removed_email_address@domain.invalid - http://segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com


#4

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.


\ / removed_email_address@domain.invalid
/lad http://www.hashbang.de

Consider this:

-1.send(“abs”)


#5

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/