Forum: Ruby on Rails Where is the send() function?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Fdefa9c08c038e0e20a0c45c10a1e678?d=identicon&s=25 Vlad Berditchevskiy (Guest)
on 2006-02-01 18:33
(Received via mailing list)
Hi,

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

,----
|   <% for column in Category.content_columns %>
|     <td><%=h category.send(column.name) %></td>
|   <% 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.

--
\  /                                       vlad@hashbang.de
 \/lad                                     http://www.hashbang.de
D810e7436feb302a3e4e6b11895a7f65?d=identicon&s=25 Gael Pourriel (Guest)
on 2006-02-01 18:39
(Received via mailing list)
58479f76374a3ba3c69b9804163f39f4?d=identicon&s=25 Eric Hodel (Guest)
on 2006-02-01 19:25
(Received via mailing list)
On Feb 1, 2006, at 9:37 AM, Gael Pourriel 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 Hodel - drbrain@segment7.net - http://segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com
Af93ba6b6b59f22a8f37e8de5702ef98?d=identicon&s=25 Bob Silva (Guest)
on 2006-02-02 04:37
(Received via mailing list)
send and __send__ are methods on the Object class in Ruby.

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


Bob Silva
http://www.railtie.net/
7c3a0706ce454a5e7c405a63fdcd2c21?d=identicon&s=25 Jim (Guest)
on 2006-02-02 04:57
Vlad Berditchevskiy wrote:
> Hi,
>
> in the tutorial "4 Days on Rails" the following code fragment is used:
>
> ,----
> |   <% for column in Category.content_columns %>
> |     <td><%=h category.send(column.name) %></td>
> |   <% 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.
>
> --
> \  /                                       vlad@hashbang.de
>  \/lad                                     http://www.hashbang.de

Consider this:

-1.send("abs")
This topic is locked and can not be replied to.