lib/surrounded/context/negotiator.rb in surrounded-0.9.4 vs lib/surrounded/context/negotiator.rb in surrounded-0.9.5
- old
+ new
@@ -12,27 +12,33 @@
def #{meth}(*args, &block)
@behaviors.instance_method(:#{meth}).bind(@object).call(*args, &block)
end
}, __FILE__, num
end
+ klass.send(:define_method, :__behaviors__) do
+ mod
+ end
klass
end
end
- identity = "__send__|object_id"
+ identity = %w[__send__ object_id equal?]
+ method_access = %w[respond_to? method __behaviors__]
+ reserved_methods = (identity + method_access).join('|')
+
# Remove all methods except the identity methods
instance_methods.reject{ |m|
- m.to_s =~ /#{identity}/
+ m.to_s =~ /#{reserved_methods}/
}.each do |meth|
undef_method meth
end
private
- def initialize(object, behaviors)
- @object, @behaviors = object, behaviors
+ def initialize(object)
+ @object, @behaviors = object, __behaviors__
end
def method_missing(meth, *args, &block)
@object.send(meth, *args, &block)
end
\ No newline at end of file