[ANN] Rails Plugin: meantime_filter for controllers (actions

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

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 :

On Jul 2, 2006, at 1:09 PM, Roman LE NEGRATE wrote:

0.1.0/rdoc/
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_______________________________________________
Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

On 7/2/06, Roman LE NEGRATE [email protected] 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 NEGRATE

Sincerely,

Tom L.
http://AllTom.com/
http://GadgetLife.org/

Le 4 juil. 06 à 04:48, Tom L. 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
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

Ezra Z. wrote:

Hey Roman-

This looks very handy. Very clean and tested code too :wink:

Thank you Ezra!

On Jul 4, 2006, at 1:02 AM, Roman LE NEGRATE wrote:

contents of the meantime_filter plugin directory, not this
directory itself.)

Best regards,
Roman_______________________________________________
Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

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?

Great plugin though Roman.

Cheers-
-Ezra_______________________________________________
Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

Ezra Z. 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

On Jul 4, 2006, at 12:16 PM, Roman wrote:

Hi Ezra,

Thanks again Ezra!
By the way, I am very happy this plugin is useful to other people :-).

Roman

Cool Roman thanks.

-Ezra

Le 4 juil. 06 à 22:58, Ezra Z. 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
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

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

On Jul 5, 2006, at 2:44 AM, Roman LE NEGRATE wrote:

class method.
http://lists.rubyonrails.org/mailman/listinfo/rails
Roman-

Awesome! I appreciate it man.

Cheers-
-Ezra_______________________________________________
Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs