Class: ScopedEnv

Inherits:
Object
  • Object
show all
Defined in:
lib/schemacop/scoped_env.rb

Instance Method Summary collapse

Constructor Details

#initialize(delegation_object, methods) ⇒ ScopedEnv

Returns a new instance of ScopedEnv



2
3
4
5
# File 'lib/schemacop/scoped_env.rb', line 2

def initialize(delegation_object, methods)
  @delegation_object = delegation_object
  @methods = methods
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(symbol, *args, &block) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/schemacop/scoped_env.rb', line 7

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

Instance Method Details

#respond_to_missing?(symbol, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/schemacop/scoped_env.rb', line 15

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