[Ruby2]how to dynamically attach :pre :post :wrap ro methods?

Discussion in 'Ruby' started by gabriele renzi, Jun 1, 2004.

  1. Hi gurus and nubys,

    Loooking forward to the syntax

    def foo:pre
    end

    I wonder: could we add preconditions without resorting to syntax?

    Would we have something like this:

    myobj.methods.each do |m|
    m.wrap:)pre) {|*args| p args }
    end

    ?
    Sounds obvious and necessary to me, but I can't remeber talks about
    this..


    TIA
     
    gabriele renzi, Jun 1, 2004
    #1
    1. Advertising

  2. On Wed, Jun 02, 2004 at 03:53:41AM +0900, gabriele renzi wrote:
    > Would we have something like this:
    >
    > myobj.methods.each do |m|
    > m.wrap:)pre) {|*args| p args }
    > end
    >
    > ?
    > Sounds obvious and necessary to me, but I can't remeber talks about
    > this..


    See
    http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/97440

    Something similar can be implemented trivially using the same principle,
    with Object#method instead of Module#instance_method and using the
    singleton class.

    --
    Running Debian GNU/Linux Sid (unstable)
    batsman dot geo at yahoo dot com

    ...Deep Hack Mode -- that mysterious and frightening state of
    consciousness where Mortal Users fear to tread.
    -- Matt Welsh
     
    Mauricio Fernández, Jun 1, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    667
  2. Aaron Fude

    To wrap or not to wrap?

    Aaron Fude, May 8, 2008, in forum: Java
    Replies:
    12
    Views:
    718
    Chronic Philharmonic
    May 10, 2008
  3. Warren Tang
    Replies:
    1
    Views:
    561
    Warren Tang
    Sep 17, 2008
  4. Lionel Thiry

    [ruby2] will '@@' disapear in ruby2?

    Lionel Thiry, Mar 12, 2005, in forum: Ruby
    Replies:
    12
    Views:
    175
    Lionel Thiry
    Mar 17, 2005
  5. Lionel Thiry
    Replies:
    3
    Views:
    116
    Lionel Thiry
    Apr 11, 2005
Loading...

Share This Page