public
Description: All the extra stuff you could want for the Mack Framework.
Homepage: http://www.mackframework.com
Clone URL: git://github.com/markbates/mack-more.git
Added rdoc to Mack::Utils::Hookable [#7 state:resolved]
markbates (author)
Wed Jul 16 13:02:47 -0700 2008
commit  cf269199f654b3c95adc7c4c1d9799717dbb59da
tree    24be20650c8b069d7702323be924564ed74b2fc9
parent  009c91b5e8033ae22e9227545effe5411b60148b
...
1
2
 
 
 
 
 
 
 
 
 
 
 
 
 
3
4
5
...
20
21
22
 
23
24
25
26
27
 
28
29
30
31
32
 
33
34
35
36
37
 
38
39
40
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
...
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
0
@@ -1,5 +1,18 @@
0
 module Mack # :nodoc:
0
   module Utils # :nodoc:
0
+    # Include this module into any class, or module, and it's methods can become hookable.
0
+    # This allows for the ability to do really nice AOP programming.
0
+    # 
0
+    # Example:
0
+    #   class User
0
+    #     def say_full_name
0
+    #       puts "mark"
0
+    #     end
0
+    #   end
0
+    #   User.before(:say_full_name) do
0
+    #     puts "hello"
0
+    #   end
0
+    #   User.new.say_full_name # => "hello" "mark"
0
     module Hookable
0
       
0
       def self.included(klass)
0
@@ -20,21 +33,25 @@ module Mack # :nodoc:
0
         klass.extend self
0
       end
0
 
0
+      # Used to prefix an instance method with the assigned block
0
       def before(name, &block)
0
         hookable_class.hooks_for(:before, name.to_sym) << block
0
         build_hook_instance_method(name)
0
       end
0
       
0
+      # Used to suffix an instance method with the assigned block
0
       def after(name, &block)
0
         hookable_class.hooks_for(:after, name.to_sym) << block
0
         build_hook_instance_method(name)
0
       end
0
       
0
+      # Used to prefix a class method with the assigned block
0
       def before_class_method(name, &block)
0
         hookable_class.hooks_for(:before_class_method, name.to_sym) << block
0
         build_hook_class_method(name)
0
       end
0
       
0
+      # Used to suffix a class method with the assigned block
0
       def after_class_method(name, &block)
0
         hookable_class.hooks_for(:after_class_method, name.to_sym) << block
0
         build_hook_class_method(name)

Comments