Sha256: a69b5f9ca884452dcb22b86c43cba2e9658bfe178206f87c7079af62b9740657

Contents?: true

Size: 647 Bytes

Versions: 16

Compression:

Stored size: 647 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
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
surrounded-0.9.0 lib/surrounded/context/negotiator.rb
surrounded-0.8.4 lib/surrounded/context/negotiator.rb
surrounded-0.8.3 lib/surrounded/context/negotiator.rb
surrounded-0.8.2 lib/surrounded/context/negotiator.rb
surrounded-0.8.1 lib/surrounded/context/negotiator.rb
surrounded-0.8.0 lib/surrounded/context/negotiator.rb
surrounded-0.7.3 lib/surrounded/context/negotiator.rb
surrounded-0.7.2 lib/surrounded/context/negotiator.rb
surrounded-0.7.1 lib/surrounded/context/negotiator.rb
surrounded-0.7.0 lib/surrounded/context/negotiator.rb
surrounded-0.6.0 lib/surrounded/context/negotiator.rb
surrounded-0.5.1 lib/surrounded/context/negotiator.rb
surrounded-0.5.0 lib/surrounded/context/negotiator.rb
surrounded-0.4.1 lib/surrounded/context/negotiator.rb
surrounded-0.4.0 lib/surrounded/context/negotiator.rb
surrounded-0.3.1 lib/surrounded/context/negotiator.rb