"args" question

0 views
Skip to first unread message

rellik

unread,
Apr 15, 2007, 2:23:32 AM4/15/07
to MOle Plugin
Sorry for all the questions.. Hopefully they will help you in
testing, and other users as documentation :)

Can you explain the use of the option "args"? It seems to be the
return value of the method that is after'ed. Is that right?

Fernand Galiana

unread,
Apr 15, 2007, 2:39:02 AM4/15/07
to mole-...@googlegroups.com
Hi Patrick,

  No worries... We are expecting lots of questions since this thing is new and
  we for sure haven't thought of all the cases...
 
  There are two cases here:

  1) The before call -- The signature goes as follows

   MyClass.before( :feature => :blee ) do | ctx, feature, *args|
      ....
   end

   where

   class MyClass
     def blee( arg1, arg2 )
        arg1
     end
   end

   When your moled block is called your will get

   ctx       => MyClass instance
   feature => :blee
   args     => [arg1, arg2]

  2) The after case - The signature goes as follows

  MyClass.after( :feature => :blee ) do |ctx, feature, ret_val, *arg|
    ....
  end

   When your moled block is called your will get

   ctx        => MyClass instance
   feature  => :blee,
   ret_val  => arg1
   args      => [arg1, arg2]

   Does this helps ? I am in the mist of reving the mole and updating the beast sample as well as the readme, docs and tests.

  Hopefully things will be clearer...

Thanks for your patience !!

-Fernand

rellik

unread,
Apr 15, 2007, 3:10:36 AM4/15/07
to MOle Plugin
Thanks for the info. You might change the API for after(), since it
currently has the following example:

MyClass.after( :feature => :blee ) do |context, feature, args,
block|
Mole::DbMole.mole_it( context, feature, context.session[:user_id],
:args => args )
end


On Apr 15, 1:39 am, "Fernand Galiana" <fernand.gali...@gmail.com>
wrote:

Fernand Galiana

unread,
Apr 15, 2007, 3:22:55 AM4/15/07
to mole-...@googlegroups.com
Thanks Patrick... It's in the current mix.

Sorry again for the confusion...

-Fernand

On 4/15/07, rellik < patrick...@gmail.com> wrote:

Thanks for the info.  You might change the API for after(), since it
currently has the following example:

  MyClass.after( :feature => :blee ) do |context, feature, args,
block|
    Mole::DbMole.mole_it( context, feature, context.session[:user_id],
                        :args => args )
  end


On Apr 15, 1:39 am, "Fernand Galiana" <fernand.gali...@gmail.com>
wrote:
> Hi Patrick,
>
>   No worries... We are expecting lots of questions since this thing is new
> and
>   we for sure haven't thought of all the cases...
>
>   There are two cases here:
>
>   1) The before call -- The signature goes as follows
>
>    MyClass.before ( :feature => :blee ) do | ctx, feature, *args|
Reply all
Reply to author
Forward
0 new messages