mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Support Method callbacks
This commit is contained in:
parent
10085114ce
commit
2f59066470
1 changed files with 8 additions and 0 deletions
|
@ -287,6 +287,14 @@ module ActiveSupport
|
|||
when Proc
|
||||
@klass.send(:define_method, method_name, &filter)
|
||||
method_name << (filter.arity == 1 ? "(self)" : "")
|
||||
when Method
|
||||
@klass.send(:define_method, "#{method_name}_method") { filter }
|
||||
@klass.class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
|
||||
def #{method_name}(&blk)
|
||||
#{method_name}_method.call(self, &blk)
|
||||
end
|
||||
RUBY_EVAL
|
||||
method_name
|
||||
when String
|
||||
@klass.class_eval <<-RUBY_EVAL
|
||||
def #{method_name}
|
||||
|
|
Loading…
Reference in a new issue