aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2010-08-05 01:15:57 +0200
committerXavier Noria <fxn@hashref.com>2010-08-05 01:15:57 +0200
commit3cbe111439b22f11670587e2ec6779533dd77090 (patch)
tree541ec151c0899e21c3bef1c4b7ad9136b42f9b2f /activesupport
parentec736dff7b0a05d58d4c8780863afc47e2bb74a3 (diff)
parentd191db76e04f065e1b0cff3766c818f9b8e2f43a (diff)
downloadrails-3cbe111439b22f11670587e2ec6779533dd77090.tar.gz
rails-3cbe111439b22f11670587e2ec6779533dd77090.tar.bz2
rails-3cbe111439b22f11670587e2ec6779533dd77090.zip
Merge remote branch 'docrails/master'
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/callbacks.rb4
-rw-r--r--activesupport/lib/active_support/concern.rb35
2 files changed, 38 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/callbacks.rb b/activesupport/lib/active_support/callbacks.rb
index 0fafd56f33..50a4ce695e 100644
--- a/activesupport/lib/active_support/callbacks.rb
+++ b/activesupport/lib/active_support/callbacks.rb
@@ -571,7 +571,9 @@ module ActiveSupport
#
# would trigger <tt>Audit#before_save</tt> instead. That's constructed by calling
# <tt>"#{kind}_#{name}"</tt> on the given instance. In this case "kind" is "before" and
- # "name" is "save".
+ # "name" is "save". In this context treat ":kind" and ":name" as special thing where
+ # ":kind" refers to "callback type(before/after)" and ":name" refers to the method on
+ # which callbacks are being defined.
#
# A declaration like
#
diff --git a/activesupport/lib/active_support/concern.rb b/activesupport/lib/active_support/concern.rb
index eb31f7cad4..408d327dd7 100644
--- a/activesupport/lib/active_support/concern.rb
+++ b/activesupport/lib/active_support/concern.rb
@@ -1,3 +1,38 @@
+# A typical module looks like this
+#
+# module M
+# def self.included(base)
+# base.send(:extend, ClassMethods)
+# base.send(:include, InstanceMethods)
+# scope :foo, :conditions => {:created_at => nil}
+# end
+#
+# module ClassMethods
+# def cm; puts 'I am class method'; end
+# end
+#
+# module InstanceMethods
+# def im; puts 'I am instance method'; end
+# end
+# end
+#
+# By using <tt>ActiveSupport::Concern</tt> above module could be written as:
+#
+# module M
+# extend ActiveSupport::Concern
+#
+# included do
+# scope :foo, :conditions => {:created_at => nil}
+# end
+#
+# module ClassMethods
+# def cm; puts 'I am class method'; end
+# end
+#
+# module InstanceMethods
+# def im; puts 'I am instance method'; end
+# end
+# end
module ActiveSupport
module Concern
def self.extended(base)