Sha256: 3e1a55830042792bdabb0c71e016ea7a594a122b4494a874eb973496328a5cd5
Contents?: true
Size: 554 Bytes
Versions: 5
Compression:
Stored size: 554 Bytes
Contents
## # A simple extension of the Proc class that supports setting a custom binding # and evaluates everything in the Proc using the new binding. class ProcWithBinding < Proc ## # Set the binding for this instance def apply_binding(bind, *args) @binding = bind instance_exec(*args, &self) end def method_missing(method, *args) begin method_from_binding = eval("method(#{method.inspect})", @binding) return method_from_binding.call(*args) rescue NameError # fall through on purpose end super end end
Version data entries
5 entries across 5 versions & 1 rubygems