Whats is the idea behind using self.method_name ????? please help





Thanks.

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Colin Law at Nov 28, 2012 at 10:04 am

    On 28 November 2012 10:00, Manoj M. wrote:
    Whats is the idea behind using self.method_name ????? please help
    The first hit in google for
    ruby def self
    is

    http://yehudakatz.com/2009/11/15/metaprogramming-in-ruby-its-all-about-the-self/

    which seems to just about cover it.

    Colin

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Frederick Cheung at Nov 28, 2012 at 10:16 am

    On Nov 28, 6:04 am, Colin Law wrote:
    On 28 November 2012 10:00, Manoj M. wrote:

    Whats is the idea behind using self.method_name ????? please help
    The first hit in google for
    ruby def self
    is

    http://yehudakatz.com/2009/11/15/metaprogramming-in-ruby-its-all-abou...

    which seems to just about cover it.
    Or it could be about disambiguating local variable versus method call.
    Hard to tell without more context.

    Fred
    Colin
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Manoj M. at Nov 28, 2012 at 10:18 am

    Colin Law wrote in post #1086832:
    On 28 November 2012 10:00, Manoj M. wrote:
    Whats is the idea behind using self.method_name ????? please help
    The first hit in google for
    ruby def self
    is

    http://yehudakatz.com/2009/11/15/metaprogramming-in-ruby-its-all-about-the-self/

    which seems to just about cover it.

    Colin
    Hello colin

    it seems tougher, can you paste a link which is in simple words

    --
    Posted via http://www.ruby-forum.com/.

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Fahim Patel at Nov 28, 2012 at 12:37 pm
    Read Class method and instance method in model .

    On Wednesday, November 28, 2012 3:30:24 PM UTC+5:30, Ruby-Forum.com User
    wrote:
    Whats is the idea behind using self.method_name ????? please help





    Thanks.

    --
    Posted via http://www.ruby-forum.com/.
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/2o-RWuH12OQJ.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Thil at Nov 28, 2012 at 12:46 pm
    Hi ,

    Self.methods is static methods using the class name itself you can call the
    methods and is not available to the instance of the class.

    Thanks,
    Senthil Srinivasan

    On Wednesday, 28 November 2012 15:30:24 UTC+5:30, Ruby-Forum.com User wrote:

    Whats is the idea behind using self.method_name ????? please help





    Thanks.

    --
    Posted via http://www.ruby-forum.com/.
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/vs5Z2L0xXL4J.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Jordon Bedwell at Nov 28, 2012 at 2:02 pm

    On Wed, Nov 28, 2012 at 6:46 AM, thil wrote:
    Self.methods is static methods using the class name itself you can call the
    methods and is not available to the instance of the class.
    There is no such thing as static methods in Ruby. self.method_name
    (or sometimes self.class.method_name) are instance methods on the
    singleton instance of the object (in 1.9 you can access the singleton
    via singleton_class too). Since everything is an object in Ruby
    (literally) you have multiple types of instances, in his case he is
    accessing instance methods on the singleton (or anonymous class or
    eigen, however you want to label it) vs instance methods on /an/
    instance of that object.

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Thil at Dec 4, 2012 at 7:26 am
    class A
    def self.b
    print "this is static methods"
    end
    end

    You can only be able to call the method "b" by using : A.b

    that wat I am trying to say.
    On Wednesday, 28 November 2012 19:32:01 UTC+5:30, Jordon Bedwell wrote:

    On Wed, Nov 28, 2012 at 6:46 AM, thil <thil...@gmail.com <javascript:>>
    wrote:
    Self.methods is static methods using the class name itself you can call the
    methods and is not available to the instance of the class.
    There is no such thing as static methods in Ruby. self.method_name
    (or sometimes self.class.method_name) are instance methods on the
    singleton instance of the object (in 1.9 you can access the singleton
    via singleton_class too). Since everything is an object in Ruby
    (literally) you have multiple types of instances, in his case he is
    accessing instance methods on the singleton (or anonymous class or
    eigen, however you want to label it) vs instance methods on /an/
    instance of that object.
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/lTNAl6MtriYJ.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Thil at Dec 4, 2012 at 7:33 am
    Hi Jordon,

    Thanks for your information and I agree on wat your saying.

    Thanks,
    Senthil Srinivasan
    On Wednesday, 28 November 2012 19:32:01 UTC+5:30, Jordon Bedwell wrote:

    On Wed, Nov 28, 2012 at 6:46 AM, thil <thil...@gmail.com <javascript:>>
    wrote:
    Self.methods is static methods using the class name itself you can call the
    methods and is not available to the instance of the class.
    There is no such thing as static methods in Ruby. self.method_name
    (or sometimes self.class.method_name) are instance methods on the
    singleton instance of the object (in 1.9 you can access the singleton
    via singleton_class too). Since everything is an object in Ruby
    (literally) you have multiple types of instances, in his case he is
    accessing instance methods on the singleton (or anonymous class or
    eigen, however you want to label it) vs instance methods on /an/
    instance of that object.
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/3b1rrqgtyPYJ.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedNov 28, '12 at 10:00a
activeDec 4, '12 at 7:33a
posts9
users6
websiterubyonrails.org
irc#RubyOnRails

People

Translate

site design / logo © 2022 Grokbase