wrap 0.6.0 → 1.0.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.
- data/lib/wrap.rb +4 -2
- data/test/wrap_test.rb +19 -0
- data/wrap.gemspec +1 -1
- metadata +3 -3
data/lib/wrap.rb
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
##
|
6
6
|
#
|
7
7
|
class << Wrap
|
8
|
-
Version = '0.
|
8
|
+
Version = '1.0.0' unless defined?(Version)
|
9
9
|
|
10
10
|
def version
|
11
11
|
Version
|
@@ -156,12 +156,14 @@
|
|
156
156
|
end
|
157
157
|
|
158
158
|
def before(name, *args, &block)
|
159
|
+
wrap(name) unless wrapped?(name)
|
159
160
|
name = wrap_expand_aliases(name)
|
160
161
|
cb = initialize_callbacks!(name)
|
161
162
|
cb.before.push(args.shift || block)
|
162
163
|
end
|
163
164
|
|
164
165
|
def after(name, *args, &block)
|
166
|
+
wrap(name) unless wrapped?(name)
|
165
167
|
name = wrap_expand_aliases(name)
|
166
168
|
cb = initialize_callbacks!(name)
|
167
169
|
cb.after.push(args.shift || block)
|
@@ -216,7 +218,7 @@
|
|
216
218
|
list = []
|
217
219
|
|
218
220
|
self.class.ancestors.each do |ancestor|
|
219
|
-
|
221
|
+
next unless ancestor.respond_to?(:callbacks)
|
220
222
|
|
221
223
|
if ancestor.callbacks.is_a?(Map) and ancestor.callbacks[name].is_a?(Map)
|
222
224
|
callbacks = ancestor.callbacks[name][which]
|
data/test/wrap_test.rb
CHANGED
@@ -62,6 +62,25 @@ Testing Wrap do
|
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
|
+
##
|
66
|
+
#
|
67
|
+
testing 'that :before and :after will auto-wrap methods iff needed' do
|
68
|
+
assert do
|
69
|
+
wrapped_class do
|
70
|
+
before(:foo){ accum.push(:before) }
|
71
|
+
after(:foo){ accum.push(:after) }
|
72
|
+
|
73
|
+
define_method(:foo){ accum.push(42) }
|
74
|
+
|
75
|
+
assert {
|
76
|
+
c = new
|
77
|
+
c.foo()
|
78
|
+
c.accum == [:before, 42, :after]
|
79
|
+
}
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
65
84
|
##
|
66
85
|
#
|
67
86
|
testing 'that callbacks are halted with "false" iff they return "false"' do
|
data/wrap.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-12-03 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: map
|
16
|
-
requirement: &
|
16
|
+
requirement: &70227560830640 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: 4.7.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70227560830640
|
25
25
|
description: ! 'description: wrap kicks the ass'
|
26
26
|
email: ara.t.howard@gmail.com
|
27
27
|
executables: []
|