Sha256: 7d0919e750595818229019f68e6c1d340f65901e10733bc7a39647b354fcfcea
Contents?: true
Size: 690 Bytes
Versions: 1
Compression:
Stored size: 690 Bytes
Contents
module Surrounded module Context class Negotiator identity = "__send__|object_id" instance_methods.each do |meth| unless meth.to_s =~ /#{identity}/ undef_method meth end end private def initialize(object, behaviors) @object, @behaviors = object, behaviors end def method_missing(meth, *args, &block) if @behaviors.instance_methods.include?(meth) the_method = @behaviors.instance_method(meth) the_method.bind(@object).call(*args, &block) else @object.send(meth, *args, &block) end end end Negotiator.send(:prepend, Surrounded) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
surrounded-0.9.1 | lib/surrounded/context/negotiator.rb |