Sha256: 15f07a978a5f02ab2f99f9ca54793fadc2aa080fe34d8efb45dd3ee8e18a9533

Contents?: true

Size: 560 Bytes

Versions: 6

Compression:

Stored size: 560 Bytes

Contents

module Taketo
  module Support

    ##
    # This module allows to use external
    # methods in block used by instance_eval,
    # that it effectively mimics real closure
    #
    module EvalDelegator
      def evaluate(&block)
        @external_self = eval "self", block.binding
        self.instance_eval(&block)
      end

      def method_missing(method_name, *args, &block)
        if @external_self.respond_to?(method_name)
          @external_self.send(method_name, *args, &block)
        else
          super
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
taketo-0.0.6 lib/taketo/support/eval_delegator.rb
taketo-0.0.5 lib/taketo/support/eval_delegator.rb
taketo-0.0.4 lib/taketo/support/eval_delegator.rb
taketo-0.0.3 lib/taketo/support/eval_delegator.rb
taketo-0.0.2 lib/taketo/support/eval_delegator.rb
taketo-0.0.1 lib/taketo/support/eval_delegator.rb