Roman LE NEGRATE
2006-Jul-02 19:53 UTC
[Rails] [ANN] Rails Plugin: meantime_filter for controllers (actions within blocks)
Hello, I just finished writing a plugin for Rails that I''m annoucing the first release here: meantime_filter. It is descibed at http://roman2k.free.fr/rails/meantime_filter/0.1.0/ rdoc/ (See the end of this message for getting it.) ABOUT THE PLUGIN It extends ActionController to add the functionnality of having filters run at the action call time. This new type of filter yields when the action has to be performed. Especially, it enables one to use all the power of the ActiveRecord::Base.with_scope class method in actions. For example (in a controller definition): before_filter :authenticate # Sets @user to the logged in user meantime_filter :scope_to_user, :only => :list # Displays the posts of @user only. def list @posts = Post.find(:all) end private def scope_to_user Post.with_scope(:find => { :conditions => [''user_id = ?'', @user.id] }) { yield } end A good thing is that nested filters are supported. You can have the first filter yielding to the second that finally yields to the action. It is performed within the two blocks so that you can use nested with_scope cleanly and easily without having to touch the protected class method "scoped_methods" of your models. For example (still in a controller definition): meantime_filter :scope_to_user_group meantime_filter :scope_to_user, :only => :show Please read the RDoc documentation for more informations. DOWNLOADING THE PLUGIN (and documentation) While the RubyForge project request is being examined for opening, I put the plugin archive and RDoc on a temporary site: - Download at: http://roman2k.free.fr/rails/meantime_filter/0.1.0/ plugin/ - RDoc at: http://roman2k.free.fr/rails/meantime_filter/0.1.0/rdoc/ I will post the URL of the RubyForge project here in this topic if/ when it has been accepted. MORE This plugin is tested. Unit tests are included in the plugin archive. Reply to this topic or email me for help or questions. Roman LE NEGRATE
Roman LE NEGRATE
2006-Jul-02 20:09 UTC
[Rails] [ANN] Rails Plugin: meantime_filter for controllers (actions within blocks)
Just corrected the download-link in the RDoc documentation (it pointed to a wrong location). Sorry for the mistake. Le 2 juil. 06 ? 21:53, Roman LE NEGRATE a ?crit :> Hello, I just finished writing a plugin for Rails that I''m > annoucing the first release here: meantime_filter. > It is descibed at http://roman2k.free.fr/rails/meantime_filter/ > 0.1.0/rdoc/ > (See the end of this message for getting it.) > > ABOUT THE PLUGIN > It extends ActionController to add the functionnality of having > filters run at the action call time. This new type of filter yields > when the action has to be performed. Especially, it enables one to > use all the power of the ActiveRecord::Base.with_scope class method > in actions. > > For example (in a controller definition): > before_filter :authenticate # Sets @user to the logged in user > meantime_filter :scope_to_user, :only => :list > > # Displays the posts of @user only. > def list > @posts = Post.find(:all) > end > > private > > def scope_to_user > Post.with_scope(:find => { :conditions => [''user_id = ?'', > @user.id] }) { yield } > end > > A good thing is that nested filters are supported. You can have the > first filter yielding to the second that finally yields to the > action. It is performed within the two blocks so that you can use > nested with_scope cleanly and easily without having to touch the > protected class method "scoped_methods" of your models. > > For example (still in a controller definition): > meantime_filter :scope_to_user_group > meantime_filter :scope_to_user, :only => :show > > Please read the RDoc documentation for more informations. > > > DOWNLOADING THE PLUGIN (and documentation) > While the RubyForge project request is being examined for opening, > I put the plugin archive and RDoc on a temporary site: > - Download at: http://roman2k.free.fr/rails/meantime_filter/ > 0.1.0/plugin/ > - RDoc at: http://roman2k.free.fr/rails/meantime_filter/0.1.0/rdoc/ > > I will post the URL of the RubyForge project here in this topic if/ > when it has been accepted. > > > MORE > This plugin is tested. Unit tests are included in the plugin archive. > Reply to this topic or email me for help or questions. > > > Roman LE NEGRATE > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Ezra Zygmuntowicz
2006-Jul-02 22:01 UTC
[Rails] [ANN] Rails Plugin: meantime_filter for controllers (actions within blocks)
On Jul 2, 2006, at 1:09 PM, Roman LE NEGRATE wrote:> Just corrected the download-link in the RDoc documentation (it > pointed to a wrong location). Sorry for the mistake. > > > > Le 2 juil. 06 ? 21:53, Roman LE NEGRATE a ?crit : > >> Hello, I just finished writing a plugin for Rails that I''m >> annoucing the first release here: meantime_filter. >> It is descibed at http://roman2k.free.fr/rails/meantime_filter/ >> 0.1.0/rdoc/ >> (See the end of this message for getting it.) >> >> ABOUT THE PLUGIN >> It extends ActionController to add the functionnality of having >> filters run at the action call time. This new type of filter >> yields when the action has to be performed. Especially, it enables >> one to use all the power of the ActiveRecord::Base.with_scope >> class method in actions. >> <snip killer stuff> >> >> MORE >> This plugin is tested. Unit tests are included in the plugin archive. >> Reply to this topic or email me for help or questions. >> >> >> Roman LE NEGRATE >>Hey Roman- This looks very handy. Very clean and tested code too ;) Thanks- -Ezra
Roman
2006-Jul-03 08:55 UTC
[Rails] Re: [ANN] Rails Plugin: meantime_filter for controllers (act
Ezra Zygmuntowicz wrote:> > Hey Roman- > > This looks very handy. Very clean and tested code too ;)Thank you Ezra! -- Posted via http://www.ruby-forum.com/.
Tom Lieber
2006-Jul-04 02:48 UTC
[Rails] [ANN] Rails Plugin: meantime_filter for controllers (actions within blocks)
On 7/2/06, Roman LE NEGRATE <roman2k@free.fr> wrote:> Hello, I just finished writing a plugin for Rails that I''m annoucing > the first release here: meantime_filter.Very convenient! I''m using it already! (Maybe now I''ll stop forgetting to keep future and draft posts from showing up...)> Roman LE NEGRATESincerely, Tom Lieber http://AllTom.com/ http://GadgetLife.org/
Roman LE NEGRATE
2006-Jul-04 08:02 UTC
[Rails] [ANN] Rails Plugin: meantime_filter for controllers (actions within blocks)
Le 4 juil. 06 ? 04:48, Tom Lieber a ?crit :> Very convenient! I''m using it already! (Maybe now I''ll stop forgetting > to keep future and draft posts from showing up...)Hi Tom, I''m pleased you find it useful :-). (And corrected the archive because it was previously holding the contents of the meantime_filter plugin directory, not this directory itself.) Best regards, Roman
Ezra Zygmuntowicz
2006-Jul-04 18:44 UTC
[Rails] [ANN] Rails Plugin: meantime_filter for controllers (actions within blocks)
On Jul 4, 2006, at 1:02 AM, Roman LE NEGRATE wrote:> > Le 4 juil. 06 ? 04:48, Tom Lieber a ?crit : >> Very convenient! I''m using it already! (Maybe now I''ll stop >> forgetting >> to keep future and draft posts from showing up...) > > Hi Tom, > I''m pleased you find it useful :-). > > (And corrected the archive because it was previously holding the > contents of the meantime_filter plugin directory, not this > directory itself.) > > Best regards, > Roman_______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/railsHey Roman- I really like your plugin and I am already using it in a few apps. My only minor nitpick is with the name meantime_filter. It doesn''t quite describe what is actually happening to me. Would there be any way to get you to create an alias for meantime_filter? Maybe around_action, wrap_action, wrap_filter or something that sounds a little closer to what this filter does? Great plugin though Roman. Cheers- -Ezra
Roman
2006-Jul-04 19:16 UTC
[Rails] Re: [ANN] Rails Plugin: meantime_filter for controllers (act
Ezra Zygmuntowicz wrote:> Hey Roman- > > I really like your plugin and I am already using it in a few apps. > My only minor nitpick is with the name meantime_filter. It doesn''t > quite describe what is actually happening to me. Would there be any > way to get you to create an alias for meantime_filter? Maybe > around_action, wrap_action, wrap_filter or something that sounds a > little closer to what this filter does?Hi Ezra, Yes of course I can add an alias or set "meantime_filter" as an alias of the other name. I chose "meantime" because I did not know any other english word describing what this type of filter does. "around_filter" did fit into its role but was already taken in the Rails core. Indeed, "wrap_filter" sounds a lot better! And I will release the v0.1.1 tomorrow with this alias added.> Great plugin though Roman.Thanks again Ezra! By the way, I am very happy this plugin is useful to other people :-). Roman -- Posted via http://www.ruby-forum.com/.
Ezra Zygmuntowicz
2006-Jul-04 20:58 UTC
[Rails] Re: [ANN] Rails Plugin: meantime_filter for controllers (act
On Jul 4, 2006, at 12:16 PM, Roman wrote:> Ezra Zygmuntowicz wrote: >> Hey Roman- >> >> I really like your plugin and I am already using it in a few apps. >> My only minor nitpick is with the name meantime_filter. It doesn''t >> quite describe what is actually happening to me. Would there be any >> way to get you to create an alias for meantime_filter? Maybe >> around_action, wrap_action, wrap_filter or something that sounds a >> little closer to what this filter does? > > Hi Ezra, > > Yes of course I can add an alias or set "meantime_filter" as an > alias of > the other name. I chose "meantime" because I did not know any other > english word describing what this type of filter does. "around_filter" > did fit into its role but was already taken in the Rails core. Indeed, > "wrap_filter" sounds a lot better! And I will release the v0.1.1 > tomorrow with this alias added. > >> Great plugin though Roman. > > Thanks again Ezra! > By the way, I am very happy this plugin is useful to other people :-). > > > RomanCool Roman thanks. -Ezra
Roman LE NEGRATE
2006-Jul-05 09:44 UTC
[Rails] Re: [ANN] Rails Plugin: meantime_filter for controllers (act
Le 4 juil. 06 ? 22:58, Ezra Zygmuntowicz a ?crit :> > Cool Roman thanks.Hello :-), v0.1.1 of the plugin is released. The aliases Ezra requested have been implemented: wrap_filter and wrap_actions do the same thing as the previous meantime_filter class method. It can be downloaded from: http://roman2k.free.fr/rails/meantime_filter/0.1.1/plugin/ meantime_filter-0.1.1.tar.gz Documentation is available at: http://roman2k.free.fr/rails/meantime_filter/0.1.1/rdoc/
Ezra Zygmuntowicz
2006-Jul-05 16:09 UTC
[Rails] Re: [ANN] Rails Plugin: meantime_filter for controllers (act
On Jul 5, 2006, at 2:44 AM, Roman LE NEGRATE wrote:> Le 4 juil. 06 ? 22:58, Ezra Zygmuntowicz a ?crit : >> >> Cool Roman thanks. > > Hello :-), > > v0.1.1 of the plugin is released. > > The aliases Ezra requested have been implemented: wrap_filter and > wrap_actions do the same thing as the previous meantime_filter > class method. > > It can be downloaded from: > http://roman2k.free.fr/rails/meantime_filter/0.1.1/plugin/ > meantime_filter-0.1.1.tar.gz > > Documentation is available at: > http://roman2k.free.fr/rails/meantime_filter/0.1.1/rdoc/ > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/railsRoman- Awesome! I appreciate it man. Cheers- -Ezra
Roman LE NEGRATE
2006-Nov-04 01:59 UTC
[Rails] Re: [ANN] Rails Plugin: meantime_filter for controllers (act
Hi, meantime_filter plugin v0.1.2 is released solving a small issue related to Method#call and safe-level (refer to http:// blog.outerim.com/articles/2006/08/01/meantime-filter for more informations). It is available at http://roman2k.free.fr/rails/meantime_filter/0.1.2/ rdoc/ -Roman