wrap 0.6.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/lib/wrap.rb +4 -2
  2. data/test/wrap_test.rb +19 -0
  3. data/wrap.gemspec +1 -1
  4. metadata +3 -3
@@ -5,7 +5,7 @@
5
5
  ##
6
6
  #
7
7
  class << Wrap
8
- Version = '0.6.0' unless defined?(Version)
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
- break unless ancestor.respond_to?(:callbacks)
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]
@@ -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
@@ -3,7 +3,7 @@
3
3
 
4
4
  Gem::Specification::new do |spec|
5
5
  spec.name = "wrap"
6
- spec.version = "0.6.0"
6
+ spec.version = "1.0.0"
7
7
  spec.platform = Gem::Platform::RUBY
8
8
  spec.summary = "wrap"
9
9
  spec.description = "description: wrap kicks the ass"
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.6.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: &70247178773500 !ruby/object:Gem::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: *70247178773500
24
+ version_requirements: *70227560830640
25
25
  description: ! 'description: wrap kicks the ass'
26
26
  email: ara.t.howard@gmail.com
27
27
  executables: []