contracts 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/decorators.rb +5 -1
- metadata +1 -1
data/lib/decorators.rb
CHANGED
@@ -30,6 +30,7 @@ module MethodDecorators
|
|
30
30
|
# attr_accessor on the class variable decorated_methods
|
31
31
|
class << self; attr_accessor :decorated_methods; end
|
32
32
|
|
33
|
+
is_private = nil
|
33
34
|
decorators.each do |klass, args|
|
34
35
|
# a reference to the method gets passed into the contract here. This is good because
|
35
36
|
# we are going to redefine this method with a new name below...so this reference is
|
@@ -38,9 +39,11 @@ module MethodDecorators
|
|
38
39
|
if is_class_method
|
39
40
|
decorator = klass.new(self, method(name), *args)
|
40
41
|
@decorated_methods[:class_methods][name] = decorator
|
42
|
+
is_private = self.private_methods.include?(name)
|
41
43
|
else
|
42
44
|
decorator = klass.new(self, instance_method(name), *args)
|
43
45
|
@decorated_methods[:instance_methods][name] = decorator
|
46
|
+
is_private = self.private_instance_methods.include?(name)
|
44
47
|
end
|
45
48
|
end
|
46
49
|
|
@@ -55,7 +58,8 @@ module MethodDecorators
|
|
55
58
|
raise "Couldn't find decorator for method " + self.class.name + ":#{name}.\nDoes this method look correct to you? If you are using contracts from rspec, rspec wraps classes in it's own class.\nLook at the specs for contracts.ruby as an example of how to write contracts in this case."
|
56
59
|
end
|
57
60
|
this.decorated_methods[#{is_class_method ? ":class_methods" : ":instance_methods"}][#{name.inspect}].call_with(self, *args, &blk)
|
58
|
-
end
|
61
|
+
end
|
62
|
+
#{is_private ? "private #{name.inspect}" : ""}
|
59
63
|
ruby_eval
|
60
64
|
end
|
61
65
|
|