Sha256: 3f295562be0b9690ecc7369cb44d8c0aba60e8a38fc9004d0b8c5f1d5b6e285f
Contents?: true
Size: 698 Bytes
Versions: 16
Compression:
Stored size: 698 Bytes
Contents
# A sub context takes in a hash of local variables that should be available # in front of the current context. It basically proxies the local variables # first, then failing those proxies the context. class SubContext attr_reader :locals def initialize(locals, context=nil) @locals = locals.stringify_keys @context = context end def method_missing(method_name, *args, &block) method_name = method_name.to_s if @locals[method_name] return @locals[method_name] elsif @context return @context.send(method_name, *args, &block) end raise NoMethodError.new("undefined method `#{method_name}' for \"#{self.inspect}\":#{self.class.to_s}") end end
Version data entries
16 entries across 16 versions & 1 rubygems