Sha256: eb77eccd42bf9bef6d9b365d6bc422fdfd351b61e20a7c0ead89ec009502fe09

Contents?: true

Size: 623 Bytes

Versions: 2

Compression:

Stored size: 623 Bytes

Contents

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

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
workhorse-0.6.1 lib/workhorse/scoped_env.rb
workhorse-0.6.0 lib/workhorse/scoped_env.rb