- Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathinstance_aspect.rb
32 lines (25 loc) · 647 Bytes
/
instance_aspect.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__),'..','lib'))
require'aspector'
# Example that shows how to use Aspector with a single instance
classExampleClass
deftest
puts'test'
end
end
# Aspect that will be applied on an instance
classInstanceAspect < Aspector::Base
targetdo
defdo_this
puts'do_this'
end
end
before:test,:do_this
before:testdo
puts'do_that'
end
end
asp_instance=ExampleClass.new
not_instance=ExampleClass.new
InstanceAspect.apply(asp_instance)
asp_instance.test# This instance will have an aspect added
not_instance.test# This instance wont have aspect added