Sha256: 132de7e14dc1fb51adf307882230965b682b11cde4667a6f26295d016964be3b

Contents?: true

Size: 806 Bytes

Versions: 1

Compression:

Stored size: 806 Bytes

Contents

module Schemacop
  class ScopedEnv
    def initialize(delegation_object, methods, backup_binding = nil, prefix = nil)
      @delegation_object = delegation_object
      @methods = methods
      @backup_binding = backup_binding
      @prefix = prefix
    end

    def method_missing(symbol, *args, &block)
      symbol = :"#{@prefix}#{symbol}" if @prefix

      if @methods.include?(symbol)
        if @delegation_object.respond_to?(symbol)
          @delegation_object.send(symbol, *args, &block)
        elsif @backup_binding.respond_to?(symbol)
          @backup_binding.send(symbol, *args, &block)
        else
          super
        end
      else
        super
      end
    end

    def respond_to_missing?(symbol, include_private = false)
      @methods.include?(symbol) || super
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
schemacop-3.0.0.rc0 lib/schemacop/scoped_env.rb