Sha256: 864f0bd2c609859da5919adedbebe2ecea38dabafd653dd6a688a366393c857a
Contents?: true
Size: 1.02 KB
Versions: 2
Compression:
Stored size: 1.02 KB
Contents
class RakeCommander module RakeContext class Wrapper # Allows to interact with rake # @note this prevents subclass overlap methods to be used def context(object = global_instance, &block) raise ArgumentError, "Block required" unless block_given? object.instance_eval(&block) end def respond_to_missing?(meth, *args) global_instance.send(:respond_to_missing?, meth, *args) || super end def respond_to?(meth, with_private = true) global_instance.respond_to?(meth, with_private) || super end # Forward def method_missing(meth, *args, **kargs, &block) if respond_to?(meth) context do send(meth, *args, **kargs, &block) end else super end end private # Refers to the top level object def global_instance @global_instance ||= eval('self', TOPLEVEL_BINDING, __FILE__, __LINE__) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rake-commander-0.1.4 | lib/rake-commander/rake_context/wrapper.rb |
rake-commander-0.1.2 | lib/rake-commander/rake_context/wrapper.rb |