diff --git a/activemodel/lib/active_model/serialization.rb b/activemodel/lib/active_model/serialization.rb index 5670ec74cbb10..e675937f4d71f 100644 --- a/activemodel/lib/active_model/serialization.rb +++ b/activemodel/lib/active_model/serialization.rb @@ -61,6 +61,8 @@ module ActiveModel # person.serializable_hash # => {"name"=>"Bob"} # person.to_json # => "{\"name\":\"Bob\"}" # person.to_xml # => "\n:only, :except and :methods . module Serialization def serializable_hash(options = nil) options ||= {} diff --git a/activesupport/lib/active_support/callbacks.rb b/activesupport/lib/active_support/callbacks.rb index 1c7802f7de8e2..adabdd3388651 100644 --- a/activesupport/lib/active_support/callbacks.rb +++ b/activesupport/lib/active_support/callbacks.rb @@ -568,7 +568,9 @@ def reset_callbacks(symbol) # # would trigger Audit#before_save instead. That's constructed by calling # "#{kind}_#{name}" 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 eb31f7cad446e..408d327dd7955 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 ActiveSupport::Concern 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)