What does #self.included(base) do in Ruby on Rails' Restful Authentication? -


i thought do

helper_method :current_user, :logged_in?, :authorized? 

to make these controller methods available use helper methods in views. in restful authentication's lib/authenticated_system.rb, see:

# inclusion hook make #current_user , #logged_in? # available actionview helper methods. def self.included(base)   base.send :helper_method, :current_user, :logged_in?, :authorized? if base.respond_to? :helper_method end 

why done way instead of single line? also, don't see included being called anywhere.

the self.included function called when module included. allows methods executed in context of base (where module included).

more info: a ruby mixin tutorial.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -