Class: Coppy::Environment

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/coppy/environment.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(mid, *args) ⇒ Object



9
10
11
12
13
14
# File 'lib/coppy/environment.rb', line 9

def method_missing(mid, *args)
  return super if mid.to_s.end_with?('=')
  return @table[mid] if @table.key?(mid)
  return _parent.send(mid, *args) if _parent
  super
end

Instance Method Details

#subenv(hash = {}) ⇒ Object



5
6
7
# File 'lib/coppy/environment.rb', line 5

def subenv(hash = {})
  self.class.new(_parent: self, **hash)
end