easy_callbacks 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.rdoc +29 -2
- data/changelog.txt +4 -0
- data/lib/easy_callbacks/base.rb +17 -16
- data/lib/easy_callbacks/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78cd29e96e4f33597087840a931d11e87814ed37
|
4
|
+
data.tar.gz: 150a4c2f8d45946662ec580ec9bb0b030de92182
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2825eb20a91976a4aef8f578de2af31381edefb55a232e820761b5974682c56088dd7174dc20f3ce9cee49567f6849764fc623badc02e47bb4292a1840585ffc
|
7
|
+
data.tar.gz: 8a8f9402da6216a8eb3204b9df913cd840d6706f56103632982a81901891f92029e4a1f7fbdee00932c358b56bdfe14a00aabb3cf19b3ea753c16087317bc6e8
|
data/README.rdoc
CHANGED
@@ -54,10 +54,11 @@ For anonymous callbacks:
|
|
54
54
|
|
55
55
|
{
|
56
56
|
class: SomeClass,
|
57
|
+
object: #<SomeClass:0x00000002b65ab0>,
|
57
58
|
target: :some_method,
|
58
59
|
type: :before,
|
59
60
|
callback_name: nil,
|
60
|
-
proc:
|
61
|
+
proc: #<Proc:0x00000002655a20@...>
|
61
62
|
}
|
62
63
|
|
63
64
|
For around callbacks (with success):
|
@@ -81,9 +82,35 @@ For around callbacks (with error):
|
|
81
82
|
callback_name: :do_it_around,
|
82
83
|
proc: nil,
|
83
84
|
return_type: :error,
|
84
|
-
return_object:
|
85
|
+
return_object: #<StandardError: StandardError>
|
85
86
|
}
|
86
87
|
|
88
|
+
== Singleton Classes Support
|
89
|
+
|
90
|
+
It works too:
|
91
|
+
|
92
|
+
class SomeClass
|
93
|
+
|
94
|
+
class << self
|
95
|
+
|
96
|
+
def some_method(some_arg)
|
97
|
+
puts some_arg
|
98
|
+
end
|
99
|
+
|
100
|
+
include EasyCallbacks::Base
|
101
|
+
|
102
|
+
# ...
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
107
|
+
|
108
|
+
SomeClass.some_method 'some arg'
|
109
|
+
|
110
|
+
== Changelog
|
111
|
+
|
112
|
+
See 'changelog.txt' to follow the progress.
|
113
|
+
|
87
114
|
===
|
88
115
|
|
89
116
|
{<img src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" alt="Donate" />}[https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=9KHDLTWYK9A62]
|
data/changelog.txt
ADDED
data/lib/easy_callbacks/base.rb
CHANGED
@@ -7,25 +7,25 @@ module EasyCallbacks
|
|
7
7
|
|
8
8
|
include MethodDecorator
|
9
9
|
|
10
|
-
TYPES = %w(before around after)
|
11
|
-
|
12
10
|
class << self
|
13
11
|
|
14
12
|
attr_accessor :callbacks
|
15
13
|
|
16
|
-
def
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
14
|
+
def before(target, callback_name=nil, &block)
|
15
|
+
handle_callback_definition :before, target, callback_name, &block
|
16
|
+
end
|
17
|
+
|
18
|
+
def around(target, callback_name=nil, &block)
|
19
|
+
handle_callback_definition :around, target, callback_name, &block
|
20
|
+
end
|
21
|
+
|
22
|
+
def after(target, callback_name=nil, &block)
|
23
|
+
handle_callback_definition :after, target, callback_name, &block
|
24
24
|
end
|
25
25
|
|
26
26
|
private
|
27
27
|
|
28
|
-
def
|
28
|
+
def handle_callback_definition(type, target, callback_name, &block)
|
29
29
|
push_callback type, target, callback_name, &block
|
30
30
|
decorate_target target
|
31
31
|
end
|
@@ -61,10 +61,6 @@ module EasyCallbacks
|
|
61
61
|
end unless method_defined? original_method_name_for(target)
|
62
62
|
end
|
63
63
|
|
64
|
-
def respond_to_missing?(target, include_private=false)
|
65
|
-
TYPES.include?(target) ? true : super ;
|
66
|
-
end
|
67
|
-
|
68
64
|
end
|
69
65
|
|
70
66
|
def execute_callbacks_for(type, target, additional_options, *args, &block)
|
@@ -82,7 +78,12 @@ module EasyCallbacks
|
|
82
78
|
|
83
79
|
arguments.last.merge! additional_options if additional_options
|
84
80
|
|
85
|
-
proc.nil?
|
81
|
+
if proc.nil?
|
82
|
+
send(cn, *arguments, &block)
|
83
|
+
else
|
84
|
+
arguments.last.merge! object: self
|
85
|
+
proc.nil? ? send(cn, *arguments, &block) : proc.call(*arguments, &block)
|
86
|
+
end
|
86
87
|
end
|
87
88
|
end
|
88
89
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easy_callbacks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- r4z3c
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -107,6 +107,7 @@ files:
|
|
107
107
|
- MIT-LICENSE
|
108
108
|
- README.rdoc
|
109
109
|
- Rakefile
|
110
|
+
- changelog.txt
|
110
111
|
- easy_callbacks.gemspec
|
111
112
|
- lib/easy_callbacks.rb
|
112
113
|
- lib/easy_callbacks/base.rb
|