Sha256: 726e54cea28c44bfe4e16402386972d5886df303f0aaae5dee8662ee93846ee5

Contents?: true

Size: 821 Bytes

Versions: 31

Compression:

Stored size: 821 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

    ruby2_keywords 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

31 entries across 31 versions & 1 rubygems

Version Path
schemacop-3.0.29 lib/schemacop/scoped_env.rb
schemacop-3.0.28 lib/schemacop/scoped_env.rb
schemacop-3.0.27 lib/schemacop/scoped_env.rb
schemacop-3.0.26 lib/schemacop/scoped_env.rb
schemacop-3.0.25 lib/schemacop/scoped_env.rb
schemacop-3.0.24 lib/schemacop/scoped_env.rb
schemacop-3.0.23 lib/schemacop/scoped_env.rb
schemacop-3.0.22 lib/schemacop/scoped_env.rb
schemacop-3.0.21 lib/schemacop/scoped_env.rb
schemacop-3.0.20 lib/schemacop/scoped_env.rb
schemacop-3.0.19 lib/schemacop/scoped_env.rb
schemacop-3.0.18 lib/schemacop/scoped_env.rb
schemacop-3.0.17 lib/schemacop/scoped_env.rb
schemacop-3.0.16 lib/schemacop/scoped_env.rb
schemacop-3.0.15 lib/schemacop/scoped_env.rb
schemacop-3.0.14 lib/schemacop/scoped_env.rb
schemacop-3.0.13 lib/schemacop/scoped_env.rb
schemacop-3.0.12 lib/schemacop/scoped_env.rb
schemacop-3.0.11 lib/schemacop/scoped_env.rb
schemacop-3.0.10 lib/schemacop/scoped_env.rb